Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-01-27 15:06:40
Exec Total Coverage
Lines: 1719 3952 43.5%
Functions: 126 338 37.3%
Branches: 922 2710 34.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101 bool is_sys_pal = false;
102 extern PALETTE* hw_palette;
103 extern bool update_hw_pal;
104 extern const char* dmaplist(int32_t index, int32_t* list_size);
105
106
107 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
108 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
109 //extern byte refresh_select_screen;
110 //extern movingblock mblock2; //mblock[4]?
111 //extern int32_t db;
112
113 static const char *ZC_str = "Zelda Classic";
114 extern char save_file_name[1024];
115 #ifdef ALLEGRO_DOS
116 const char *qst_dir_name = "dos_qst_dir";
117 #elif defined(ALLEGRO_WINDOWS)
118 const char *qst_dir_name = "win_qst_dir";
119 static const char *qst_module_name = "current_module";
120 #elif defined(ALLEGRO_LINUX)
121 const char *qst_dir_name = "linux_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(__APPLE__)
124 const char *qst_dir_name = "osx_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #endif
127 #ifdef ALLEGRO_LINUX
128 static const char *samplepath = "samplesoundset/patches.dat";
129 #endif
130 char qst_files_path[2048];
131
132 #ifdef _MSC_VER
133 #define getcwd _getcwd
134 #endif
135
136 bool rF11();
137 bool rI();
138 bool rQ();
139 bool zc_key_pressed();
140
141 #ifdef _WIN32
142
143 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
144 extern "C"
145 {
146 typedef HRESULT(WINAPI *t_DwmFlush)();
147 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
148 }
149
150 void do_DwmFlush()
151 {
152 static HMODULE shell = LoadLibrary("dwmapi.dll");
153
154 if(!shell)
155 return;
156
157 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
158 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
159
160 BOOL enabled;
161 isEnabled(&enabled);
162
163 if(isEnabled)
164 flush();
165 }
166
167 #endif // _WIN32
168
169 // Dialogue largening
170 void large_dialog(DIALOG *d)
171 {
172 large_dialog(d, 1.5);
173 }
174
175 void large_dialog(DIALOG *d, float RESIZE_AMT)
176 {
177 if(!d[0].d1)
178 {
179 d[0].d1 = 1;
180 int32_t oldwidth = d[0].w;
181 int32_t oldheight = d[0].h;
182 int32_t oldx = d[0].x;
183 int32_t oldy = d[0].y;
184 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
185 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
186 d[0].w = int32_t(d[0].w*RESIZE_AMT);
187 d[0].h = int32_t(d[0].h*RESIZE_AMT);
188
189 for(int32_t i=1; d[i].proc !=NULL; i++)
190 {
191 // Place elements horizontally
192 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
193 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
194
195 if(d[i].proc != d_stringloader)
196 {
197 if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].w *= 2;
200 }
201 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
202 }
203
204 // Place elements vertically
205 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
206 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
207
208 // Vertically resize elements
209 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
210 {
211 d[i].h = int32_t((double)d[i].h*1.5);
212 }
213 else if(d[i].proc == jwin_droplist_proc)
214 {
215 d[i].y += int32_t((double)d[i].h*0.25);
216 d[i].h = int32_t((double)d[i].h*1.25);
217 }
218 else if(d[i].proc==d_bitmap_proc)
219 {
220 d[i].h *= 2;
221 }
222 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
223
224 // Fix frames
225 if(d[i].proc == jwin_frame_proc)
226 {
227 d[i].x++;
228 d[i].y++;
229 d[i].w-=4;
230 d[i].h-=4;
231 }
232 }
233 }
234
235 for(int32_t i=1; d[i].proc!=NULL; i++)
236 {
237 if(d[i].proc==jwin_slider_proc)
238 continue;
239
240 // Bigger font
241 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
242
243 if(!d[i].dp2 && bigfontproc)
244 {
245 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
246 d[i].dp2 = lfont_l;
247 }
248 else if(!bigfontproc)
249 {
250 // ((ListData *)d[i].dp)->font = &sfont3;
251 ((ListData *)d[i].dp)->font = &lfont_l;
252 }
253
254 // Make checkboxes work
255 if(d[i].proc == jwin_check_proc)
256 d[i].proc = jwin_checkfont_proc;
257 else if(d[i].proc == jwin_radio_proc)
258 d[i].proc = jwin_radiofont_proc;
259 }
260
261 jwin_center_dialog(d);
262 }
263
264
265 /**********************************/
266 /******** System functions ********/
267 /**********************************/
268
269 static char cfg_sect[] = "zeldadx"; //We need to rename this.
270 static char ctrl_sect[] = "Controls";
271 static char sfx_sect[] = "Volume";
272
273 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
274 {
275 return D_O_K;
276 }
277
278 24 void load_game_configs()
279 {
280 24 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
281 24 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
282 24 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
283 24 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
284 24 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
285 24 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
286 24 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
287 24 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
288 24 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
289 24 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
290 24 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
291 24 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
292 24 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
293 24 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
294 24 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
295
296 //cheat modifier keya
297 24 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
298 24 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
299 24 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
300 24 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
301
302
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
303 joystick_index = 0;
304
305 24 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
306 24 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
307 24 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
308 24 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
309 24 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
310 24 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
311 24 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
312 24 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
313 24 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
314 24 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
315
316 24 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
317 24 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
318 24 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
319 24 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
320
321 24 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
322 24 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
323 24 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
324 24 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
325 24 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
326 24 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
327 24 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
328 24 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
329 24 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
330 24 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
331 24 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
332
333 24 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
334 24 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
335 24 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
336 24 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
337
338 24 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
339
340 24 digi_volume = zc_get_config(sfx_sect,"digi",248);
341 24 midi_volume = zc_get_config(sfx_sect,"midi",255);
342 24 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
343 24 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
344 24 pan_style = zc_get_config(sfx_sect,"pan",1);
345 // 1 <= zcmusic_bufsz <= 128
346 24 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
347 24 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
348 24 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
349 24 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
350 24 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
351 24 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
352 24 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
353 #ifdef __EMSCRIPTEN__
354 if (em_is_mobile()) NameEntryMode = 2;
355 #endif
356 24 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
357 24 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
358 24 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
359 24 title_version = zc_get_config(cfg_sect,"title",2);
360 24 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
361 24 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
362
363 //default - scale x2, 640 x 480
364 24 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
365 24 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
366 24 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
367 24 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
368 24 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
369
370 24 loadlast = zc_get_config(cfg_sect,"load_last",0);
371
372 24 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
373
374 24 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
375
376 24 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
377
378 #ifdef _WIN32
379 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
380 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
381 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
382 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
383
384 // This one's for Aero
385 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
386
387 // And this one fixes patches unloading on some MIDI setups
388 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
389 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
390 #else //UNIX
391 24 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
392 24 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
393 24 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
394 #endif
395 24 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
396
397 24 char const* default_path = "";
398 24 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
399
400
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(strlen(qstdir)==0)
401 {
402 24 getcwd(qstdir,2048);
403 24 fix_filename_case(qstdir);
404 24 fix_filename_slashes(qstdir);
405 24 put_backslash(qstdir);
406 24 }
407 else
408 {
409 chop_path(qstdir);
410 }
411
412 24 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
413 24 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
414 24 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
415 24 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
416 24 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
417 24 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
418 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
419 24 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
420 24 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
421 24 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
422 24 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
423 24 }
424
425 void save_control_configs(bool kb)
426 {
427 if(kb)
428 {
429 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
430 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
431 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
432 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
433
434 if (!replay_is_replaying())
435 {
436 zc_set_config(ctrl_sect,"key_a",Akey);
437 zc_set_config(ctrl_sect,"key_b",Bkey);
438 zc_set_config(ctrl_sect,"key_s",Skey);
439 zc_set_config(ctrl_sect,"key_l",Lkey);
440 zc_set_config(ctrl_sect,"key_r",Rkey);
441 zc_set_config(ctrl_sect,"key_p",Pkey);
442 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
443 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
444 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
445 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
446 zc_set_config(ctrl_sect,"key_up", DUkey);
447 zc_set_config(ctrl_sect,"key_down", DDkey);
448 zc_set_config(ctrl_sect,"key_left", DLkey);
449 zc_set_config(ctrl_sect,"key_right",DRkey);
450 }
451 }
452 else
453 {
454 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
455 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
456 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
457 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
458 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
459 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
460 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
461 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
462 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
463 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
464 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
465 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
466 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
467 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
468
469 zc_set_config(ctrl_sect,"btn_a",Abtn);
470 zc_set_config(ctrl_sect,"btn_b",Bbtn);
471 zc_set_config(ctrl_sect,"btn_s",Sbtn);
472 zc_set_config(ctrl_sect,"btn_m",Mbtn);
473 zc_set_config(ctrl_sect,"btn_l",Lbtn);
474 zc_set_config(ctrl_sect,"btn_r",Rbtn);
475 zc_set_config(ctrl_sect,"btn_p",Pbtn);
476 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
477 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
478 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
479 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
480
481 zc_set_config(ctrl_sect,"btn_up",DUbtn);
482 zc_set_config(ctrl_sect,"btn_down",DDbtn);
483 zc_set_config(ctrl_sect,"btn_left",DLbtn);
484 zc_set_config(ctrl_sect,"btn_right",DRbtn);
485 }
486 }
487
488 void save_game_configs()
489 {
490 packfile_password("");
491
492 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
493
494 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
495 {
496 int o_window_x, o_window_y;
497 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
498 zc_set_config(cfg_sect,"window_x",o_window_x);
499 zc_set_config(cfg_sect,"window_y",o_window_y);
500 }
501
502 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
503 {
504 double monitor_scale = zc_get_monitor_scale();
505 window_width = al_get_display_width(all_get_display()) / monitor_scale;
506 window_height = al_get_display_height(all_get_display()) / monitor_scale;
507 zc_set_config(cfg_sect,"window_width",window_width);
508 zc_set_config(cfg_sect,"window_height",window_height);
509 }
510
511 zc_set_config(cfg_sect,"load_last",loadlast);
512 chop_path(qstdir);
513 zc_set_config(cfg_sect,qst_dir_name,qstdir);
514 zc_set_config("SAVEFILE","save_filename",save_file_name);
515 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
516
517 flush_config_file();
518 #ifdef __EMSCRIPTEN__
519 em_sync_fs();
520 #endif
521 }
522
523 //----------------------------------------------------------------
524
525 // Timers
526
527 17310 void fps_callback()
528 {
529 17310 lastfps=framecnt;
530 17310 dword tempsecs = fps_secs;
531 17310 ++tempsecs;
532 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
533 17310 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
534 17310 ++fps_secs;
535 17310 framecnt=0;
536 17310 }
537
538 END_OF_FUNCTION(fps_callback)
539
540 24 int32_t Z_init_timers()
541 {
542 static bool didit = false;
543 const static char *err_str = "Couldn't allocate timer";
544 24 err_str = err_str; //Unused variable warning
545
546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(didit)
547 return 1;
548
549 24 didit = true;
550
551 LOCK_VARIABLE(lastfps);
552 LOCK_VARIABLE(framecnt);
553 LOCK_FUNCTION(fps_callback);
554
555
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
556 return 0;
557
558 24 return 1;
559 24 }
560
561 void Z_remove_timers()
562 {
563 remove_int(fps_callback);
564 }
565
566 //----------------------------------------------------------------
567
568 void go()
569 {
570 scare_mouse();
571 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
572 unscare_mouse();
573 }
574
575 void comeback()
576 {
577 scare_mouse();
578 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
579 unscare_mouse();
580 }
581
582 void dump_pal(BITMAP *dest)
583 {
584 for(int32_t i=0; i<256; i++)
585 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
586 }
587
588 //----------------------------------------------------------------
589
590 //Handles converting the mouse sprite from the .dat file
591 24 void load_mouse()
592 {
593 24 system_pal();
594 24 scare_mouse();
595 24 set_mouse_sprite(NULL);
596
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
597
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t j = 0; j < 4; ++j)
598 {
599 96 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
600 96 BITMAP* subbmp = create_bitmap_ex(8,16,16);
601
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(zcmouse[j])
602 destroy_bitmap(zcmouse[j]);
603 96 zcmouse[j] = create_bitmap_ex(8,sz,sz);
604 96 clear_bitmap(zcmouse[j]);
605 96 clear_bitmap(tmpbmp);
606 96 clear_bitmap(subbmp);
607 96 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
608
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 96 times.
1632 for(int32_t x = 0; x < 16; ++x)
609 {
610
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 1536 times.
26112 for(int32_t y = 0; y < 16; ++y)
611 {
612 24576 int32_t color = getpixel(tmpbmp, x, y);
613
5/5
✓ Branch 0 taken 22608 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 528 times.
✓ Branch 3 taken 552 times.
✓ Branch 4 taken 432 times.
24576 switch(color)
614 {
615 case dvc(1):
616 456 color = jwin_pal[jcCURSORMISC];
617 456 break;
618 case dvc(2):
619 528 color = jwin_pal[jcCURSOROUTLINE];
620 528 break;
621 case dvc(3):
622 552 color = jwin_pal[jcCURSORLIGHT];
623 552 break;
624 case dvc(5):
625 432 color = jwin_pal[jcCURSORDARK];
626 432 break;
627 }
628 24576 putpixel(subbmp, x, y, color);
629 24576 }
630 1536 }
631
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sz!=16)
632 96 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
633 else
634 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
635 96 destroy_bitmap(tmpbmp);
636 96 destroy_bitmap(subbmp);
637 96 }
638 24 set_mouse_sprite(zcmouse[0]);
639
640 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
641 24 set_palette(*hw_palette);
642 24 show_mouse(screen);
643 24 show_mouse(NULL);
644
645 24 unscare_mouse();
646 24 game_pal();
647 24 }
648
649 // sets the video mode and initializes the palette and mouse sprite
650 24 bool game_vid_mode(int32_t mode,int32_t wait)
651 {
652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
653 {
654 return false;
655 }
656
657 24 scrx = (resx-320)>>1;
658 24 scry = (resy-240)>>1;
659
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
660 96 zcmouse[q] = NULL;
661 24 load_mouse();
662 24 set_mouse_sprite(zcmouse[0]);
663
664
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 24 times.
408 for(int32_t i=240; i<256; i++)
665 384 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
666
667 24 set_palette(RAMpal);
668 24 clear_to_color(screen,BLACK);
669
670 24 rest(wait);
671 24 return true;
672 24 }
673
674 4 void null_quest()
675 {
676 char qstdat_string[2048];
677 4 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
678 4 strcat(qstdat_string,"#NESQST_NEW_QST");
679
680 #ifdef __EMSCRIPTEN__
681 // The quest template data file is not included because it's really big and isn't really needed
682 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
683 // which is much smaller.
684 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
685 #endif
686
687 4 byte skip_flags[4] = { 0 };
688
689 4 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
690 4 }
691
692 4 void init_NES_mode()
693 {
694 /*
695 // qst.dat may not load correctly without this...
696 QHeader.templatepath[0]='\0';
697
698 if(!init_colordata(true, &QHeader, &QMisc))
699 {
700 return;
701 }
702
703 loadfullpal();
704 init_tiles(false, &QHeader);
705 */
706 4 null_quest();
707 4 }
708
709 //----------------------------------------------------------------
710
711 qword trianglelines[16]=
712 {
713 0x0000000000000000ULL,
714 0xFD00000000000000ULL,
715 0xFDFD000000000000ULL,
716 0xFDFDFD0000000000ULL,
717 0xFDFDFDFD00000000ULL,
718 0xFDFDFDFDFD000000ULL,
719 0xFDFDFDFDFDFD0000ULL,
720 0xFDFDFDFDFDFDFD00ULL,
721 0xFDFDFDFDFDFDFDFDULL,
722 0x00FDFDFDFDFDFDFDULL,
723 0x0000FDFDFDFDFDFDULL,
724 0x000000FDFDFDFDFDULL,
725 0x00000000FDFDFDFDULL,
726 0x0000000000FDFDFDULL,
727 0x000000000000FDFDULL,
728 0x00000000000000FDULL,
729 };
730
731 word screen_triangles[28][32];
732 /*
733 qword triangles[4][16]= //[direction][value]
734 {
735 {
736 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
737 },
738 {
739 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
740 },
741 {
742 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
743 },
744 {
745 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
746 }
747 };
748 */
749
750
751 /*
752 byte triangles[4][16][8]= //[direction][value][line]
753 {
754 {
755 {
756 0, 0, 0, 0, 0, 0, 0, 0
757 },
758 {
759 1, 0, 0, 0, 0, 0, 0, 0
760 },
761 {
762 2, 1, 0, 0, 0, 0, 0, 0
763 },
764 {
765 3, 2, 1, 0, 0, 0, 0, 0
766 },
767 {
768 4, 3, 2, 1, 0, 0, 0, 0
769 },
770 {
771 5, 4, 3, 2, 1, 0, 0, 0
772 },
773 {
774 6, 5, 4, 3, 2, 1, 0, 0
775 },
776 {
777 7, 6, 5, 4, 3, 2, 1, 0
778 },
779 {
780 8, 7, 6, 5, 4, 3, 2, 1
781 },
782 {
783 8, 8, 7, 6, 5, 4, 3, 2
784 },
785 {
786 8, 8, 8, 7, 6, 5, 4, 3
787 },
788 {
789 8, 8, 8, 8, 7, 6, 5, 4
790 },
791 {
792 8, 8, 8, 8, 8, 7, 6, 5
793 },
794 {
795 8, 8, 8, 8, 8, 8, 7, 6
796 },
797 {
798 8, 8, 8, 8, 8, 8, 8, 7
799 },
800 {
801 8, 8, 8, 8, 8, 8, 8, 8
802 }
803 },
804 {
805 {
806 0, 0, 0, 0, 0, 0, 0, 0
807 },
808 {
809 15, 0, 0, 0, 0, 0, 0, 0
810 },
811 {
812 14, 15, 0, 0, 0, 0, 0, 0
813 },
814 {
815 13, 14, 15, 0, 0, 0, 0, 0
816 },
817 {
818 12, 13, 14, 15, 0, 0, 0, 0
819 },
820 {
821 11, 12, 13, 14, 15, 0, 0, 0
822 },
823 {
824 10, 11, 12, 13, 14, 15, 0, 0
825 },
826 {
827 9, 10, 11, 12, 13, 14, 15, 0
828 },
829 {
830 8, 9, 10, 11, 12, 13, 14, 15
831 },
832 {
833 8, 8, 9, 10, 11, 12, 13, 14
834 },
835 {
836 8, 8, 8, 9, 10, 11, 12, 13
837 },
838 {
839 8, 8, 8, 8, 9, 10, 11, 12
840 },
841 {
842 8, 8, 8, 8, 8, 9, 10, 11
843 },
844 {
845 8, 8, 8, 8, 8, 8, 9, 10
846 },
847 {
848 8, 8, 8, 8, 8, 8, 8, 9
849 },
850 {
851 8, 8, 8, 8, 8, 8, 8, 8
852 }
853 },
854 {
855 {
856 0, 0, 0, 0, 0, 0, 0, 0
857 },
858 {
859 0, 0, 0, 0, 0, 0, 0, 1
860 },
861 {
862 0, 0, 0, 0, 0, 0, 1, 2
863 },
864 {
865 0, 0, 0, 0, 0, 1, 2, 3
866 },
867 {
868 0, 0, 0, 0, 1, 2, 3, 4
869 },
870 {
871 0, 0, 0, 1, 2, 3, 4, 5
872 },
873 {
874 0, 0, 1, 2, 3, 4, 5, 6
875 },
876 {
877 0, 1, 2, 3, 4, 5, 6, 7
878 },
879 {
880 1, 2, 3, 4, 5, 6, 7, 8
881 },
882 {
883 2, 3, 4, 5, 6, 7, 8, 8
884 },
885 {
886 3, 4, 5, 6, 7, 8, 8, 8
887 },
888 {
889 4, 5, 6, 7, 8, 8, 8, 8
890 },
891 {
892 5, 6, 7, 8, 8, 8, 8, 8
893 },
894 {
895 6, 7, 8, 8, 8, 8, 8, 8
896 },
897 {
898 7, 8, 8, 8, 8, 8, 8, 8
899 },
900 {
901 8, 8, 8, 8, 8, 8, 8, 8
902 }
903 },
904 {
905 {
906 0, 0, 0, 0, 0, 0, 0, 0
907 },
908 {
909 0, 0, 0, 0, 0, 0, 0, 15
910 },
911 {
912 0, 0, 0, 0, 0, 0, 15, 14
913 },
914 {
915 0, 0, 0, 0, 0, 15, 14, 13
916 },
917 {
918 0, 0, 0, 0, 15, 14, 13, 12
919 },
920 {
921 0, 0, 0, 15, 14, 13, 12, 11
922 },
923 {
924 0, 0, 15, 14, 13, 12, 11, 10
925 },
926 {
927 0, 15, 14, 13, 12, 11, 10, 9
928 },
929 {
930 15, 14, 13, 12, 11, 10, 9, 8
931 },
932 {
933 14, 13, 12, 11, 10, 9, 8, 8
934 },
935 {
936 13, 12, 11, 10, 9, 8, 8, 8
937 },
938 {
939 12, 11, 10, 9, 8, 8, 8, 8
940 },
941 {
942 11, 10, 9, 8, 8, 8, 8, 8
943 },
944 {
945 10, 9, 8, 8, 8, 8, 8, 8
946 },
947 {
948 9, 8, 8, 8, 8, 8, 8, 8
949 },
950 {
951 8, 8, 8, 8, 8, 8, 8, 8
952 }
953 }
954 };
955 */
956
957
958
959 /*
960 for (int32_t blockrow=0; blockrow<30; ++i)
961 {
962 for (int32_t linerow=0; linerow<8; ++i)
963 {
964 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
965 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
966 {
967 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
968 ++triangleline;
969 }
970 }
971 }
972 */
973
974 // the ULL suffixes are to prevent this warning:
975 // warning: integer constant is too large for "int32_t" type
976
977 qword triangles[4][16][8]= //[direction][value][line]
978 {
979 {
980 {
981 0x0000000000000000ULL,
982 0x0000000000000000ULL,
983 0x0000000000000000ULL,
984 0x0000000000000000ULL,
985 0x0000000000000000ULL,
986 0x0000000000000000ULL,
987 0x0000000000000000ULL,
988 0x0000000000000000ULL
989 },
990 {
991 0xFD00000000000000ULL,
992 0x0000000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL,
997 0x0000000000000000ULL,
998 0x0000000000000000ULL
999 },
1000 {
1001 0xFDFD000000000000ULL,
1002 0xFD00000000000000ULL,
1003 0x0000000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL,
1007 0x0000000000000000ULL,
1008 0x0000000000000000ULL
1009 },
1010 {
1011 0xFDFDFD0000000000ULL,
1012 0xFDFD000000000000ULL,
1013 0xFD00000000000000ULL,
1014 0x0000000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL,
1017 0x0000000000000000ULL,
1018 0x0000000000000000ULL
1019 },
1020 {
1021 0xFDFDFDFD00000000ULL,
1022 0xFDFDFD0000000000ULL,
1023 0xFDFD000000000000ULL,
1024 0xFD00000000000000ULL,
1025 0x0000000000000000ULL,
1026 0x0000000000000000ULL,
1027 0x0000000000000000ULL,
1028 0x0000000000000000ULL
1029 },
1030 {
1031 0xFDFDFDFDFD000000ULL,
1032 0xFDFDFDFD00000000ULL,
1033 0xFDFDFD0000000000ULL,
1034 0xFDFD000000000000ULL,
1035 0xFD00000000000000ULL,
1036 0x0000000000000000ULL,
1037 0x0000000000000000ULL,
1038 0x0000000000000000ULL
1039 },
1040 {
1041 0xFDFDFDFDFDFD0000ULL,
1042 0xFDFDFDFDFD000000ULL,
1043 0xFDFDFDFD00000000ULL,
1044 0xFDFDFD0000000000ULL,
1045 0xFDFD000000000000ULL,
1046 0xFD00000000000000ULL,
1047 0x0000000000000000ULL,
1048 0x0000000000000000ULL
1049 },
1050 {
1051 0xFDFDFDFDFDFDFD00ULL,
1052 0xFDFDFDFDFDFD0000ULL,
1053 0xFDFDFDFDFD000000ULL,
1054 0xFDFDFDFD00000000ULL,
1055 0xFDFDFD0000000000ULL,
1056 0xFDFD000000000000ULL,
1057 0xFD00000000000000ULL,
1058 0x0000000000000000ULL
1059 },
1060 {
1061 0xFDFDFDFDFDFDFDFDULL,
1062 0xFDFDFDFDFDFDFD00ULL,
1063 0xFDFDFDFDFDFD0000ULL,
1064 0xFDFDFDFDFD000000ULL,
1065 0xFDFDFDFD00000000ULL,
1066 0xFDFDFD0000000000ULL,
1067 0xFDFD000000000000ULL,
1068 0xFD00000000000000ULL
1069 },
1070 {
1071 0xFDFDFDFDFDFDFDFDULL,
1072 0xFDFDFDFDFDFDFDFDULL,
1073 0xFDFDFDFDFDFDFD00ULL,
1074 0xFDFDFDFDFDFD0000ULL,
1075 0xFDFDFDFDFD000000ULL,
1076 0xFDFDFDFD00000000ULL,
1077 0xFDFDFD0000000000ULL,
1078 0xFDFD000000000000ULL
1079 },
1080 {
1081 0xFDFDFDFDFDFDFDFDULL,
1082 0xFDFDFDFDFDFDFDFDULL,
1083 0xFDFDFDFDFDFDFDFDULL,
1084 0xFDFDFDFDFDFDFD00ULL,
1085 0xFDFDFDFDFDFD0000ULL,
1086 0xFDFDFDFDFD000000ULL,
1087 0xFDFDFDFD00000000ULL,
1088 0xFDFDFD0000000000ULL
1089 },
1090 {
1091 0xFDFDFDFDFDFDFDFDULL,
1092 0xFDFDFDFDFDFDFDFDULL,
1093 0xFDFDFDFDFDFDFDFDULL,
1094 0xFDFDFDFDFDFDFDFDULL,
1095 0xFDFDFDFDFDFDFD00ULL,
1096 0xFDFDFDFDFDFD0000ULL,
1097 0xFDFDFDFDFD000000ULL,
1098 0xFDFDFDFD00000000ULL
1099 },
1100 {
1101 0xFDFDFDFDFDFDFDFDULL,
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFDFDULL,
1104 0xFDFDFDFDFDFDFDFDULL,
1105 0xFDFDFDFDFDFDFDFDULL,
1106 0xFDFDFDFDFDFDFD00ULL,
1107 0xFDFDFDFDFDFD0000ULL,
1108 0xFDFDFDFDFD000000ULL
1109 },
1110 {
1111 0xFDFDFDFDFDFDFDFDULL,
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFDFDULL,
1115 0xFDFDFDFDFDFDFDFDULL,
1116 0xFDFDFDFDFDFDFDFDULL,
1117 0xFDFDFDFDFDFDFD00ULL,
1118 0xFDFDFDFDFDFD0000ULL
1119 },
1120 {
1121 0xFDFDFDFDFDFDFDFDULL,
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0xFDFDFDFDFDFDFDFDULL,
1127 0xFDFDFDFDFDFDFDFDULL,
1128 0xFDFDFDFDFDFDFD00ULL
1129 },
1130 {
1131 0xFDFDFDFDFDFDFDFDULL,
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0xFDFDFDFDFDFDFDFDULL,
1138 0xFDFDFDFDFDFDFDFDULL
1139 }
1140 },
1141 {
1142 {
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL,
1148 0x0000000000000000ULL,
1149 0x0000000000000000ULL,
1150 0x0000000000000000ULL
1151 },
1152 {
1153 0x00000000000000FDULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL,
1160 0x0000000000000000ULL
1161 },
1162 {
1163 0x000000000000FDFDULL,
1164 0x00000000000000FDULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL,
1170 0x0000000000000000ULL
1171 },
1172 {
1173 0x0000000000FDFDFDULL,
1174 0x000000000000FDFDULL,
1175 0x00000000000000FDULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL,
1180 0x0000000000000000ULL
1181 },
1182 {
1183 0x00000000FDFDFDFDULL,
1184 0x0000000000FDFDFDULL,
1185 0x000000000000FDFDULL,
1186 0x00000000000000FDULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL,
1189 0x0000000000000000ULL,
1190 0x0000000000000000ULL
1191 },
1192 {
1193 0x000000FDFDFDFDFDULL,
1194 0x00000000FDFDFDFDULL,
1195 0x0000000000FDFDFDULL,
1196 0x000000000000FDFDULL,
1197 0x00000000000000FDULL,
1198 0x0000000000000000ULL,
1199 0x0000000000000000ULL,
1200 0x0000000000000000ULL
1201 },
1202 {
1203 0x0000FDFDFDFDFDFDULL,
1204 0x000000FDFDFDFDFDULL,
1205 0x00000000FDFDFDFDULL,
1206 0x0000000000FDFDFDULL,
1207 0x000000000000FDFDULL,
1208 0x00000000000000FDULL,
1209 0x0000000000000000ULL,
1210 0x0000000000000000ULL
1211 },
1212 {
1213 0x00FDFDFDFDFDFDFDULL,
1214 0x0000FDFDFDFDFDFDULL,
1215 0x000000FDFDFDFDFDULL,
1216 0x00000000FDFDFDFDULL,
1217 0x0000000000FDFDFDULL,
1218 0x000000000000FDFDULL,
1219 0x00000000000000FDULL,
1220 0x0000000000000000ULL
1221 },
1222 {
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0x00FDFDFDFDFDFDFDULL,
1225 0x0000FDFDFDFDFDFDULL,
1226 0x000000FDFDFDFDFDULL,
1227 0x00000000FDFDFDFDULL,
1228 0x0000000000FDFDFDULL,
1229 0x000000000000FDFDULL,
1230 0x00000000000000FDULL
1231 },
1232 {
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0x00FDFDFDFDFDFDFDULL,
1236 0x0000FDFDFDFDFDFDULL,
1237 0x000000FDFDFDFDFDULL,
1238 0x00000000FDFDFDFDULL,
1239 0x0000000000FDFDFDULL,
1240 0x000000000000FDFDULL
1241 },
1242 {
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0x00FDFDFDFDFDFDFDULL,
1247 0x0000FDFDFDFDFDFDULL,
1248 0x000000FDFDFDFDFDULL,
1249 0x00000000FDFDFDFDULL,
1250 0x0000000000FDFDFDULL
1251 },
1252 {
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFDFDULL,
1257 0x00FDFDFDFDFDFDFDULL,
1258 0x0000FDFDFDFDFDFDULL,
1259 0x000000FDFDFDFDFDULL,
1260 0x00000000FDFDFDFDULL
1261 },
1262 {
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0xFDFDFDFDFDFDFDFDULL,
1267 0xFDFDFDFDFDFDFDFDULL,
1268 0x00FDFDFDFDFDFDFDULL,
1269 0x0000FDFDFDFDFDFDULL,
1270 0x000000FDFDFDFDFDULL
1271 },
1272 {
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0xFDFDFDFDFDFDFDFDULL,
1278 0xFDFDFDFDFDFDFDFDULL,
1279 0x00FDFDFDFDFDFDFDULL,
1280 0x0000FDFDFDFDFDFDULL
1281 },
1282 {
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0xFDFDFDFDFDFDFDFDULL,
1289 0xFDFDFDFDFDFDFDFDULL,
1290 0x00FDFDFDFDFDFDFDULL
1291 },
1292 {
1293 0xFDFDFDFDFDFDFDFDULL,
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0xFDFDFDFDFDFDFDFDULL,
1299 0xFDFDFDFDFDFDFDFDULL,
1300 0xFDFDFDFDFDFDFDFDULL
1301 }
1302 },
1303 {
1304 {
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL,
1310 0x0000000000000000ULL,
1311 0x0000000000000000ULL,
1312 0x0000000000000000ULL
1313 },
1314 {
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL,
1322 0xFD00000000000000ULL
1323 },
1324 {
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0xFD00000000000000ULL,
1332 0xFDFD000000000000ULL
1333 },
1334 {
1335 0x0000000000000000ULL,
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0xFD00000000000000ULL,
1341 0xFDFD000000000000ULL,
1342 0xFDFDFD0000000000ULL
1343 },
1344 {
1345 0x0000000000000000ULL,
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0x0000000000000000ULL,
1349 0xFD00000000000000ULL,
1350 0xFDFD000000000000ULL,
1351 0xFDFDFD0000000000ULL,
1352 0xFDFDFDFD00000000ULL
1353 },
1354 {
1355 0x0000000000000000ULL,
1356 0x0000000000000000ULL,
1357 0x0000000000000000ULL,
1358 0xFD00000000000000ULL,
1359 0xFDFD000000000000ULL,
1360 0xFDFDFD0000000000ULL,
1361 0xFDFDFDFD00000000ULL,
1362 0xFDFDFDFDFD000000ULL
1363 },
1364 {
1365 0x0000000000000000ULL,
1366 0x0000000000000000ULL,
1367 0xFD00000000000000ULL,
1368 0xFDFD000000000000ULL,
1369 0xFDFDFD0000000000ULL,
1370 0xFDFDFDFD00000000ULL,
1371 0xFDFDFDFDFD000000ULL,
1372 0xFDFDFDFDFDFD0000ULL
1373 },
1374 {
1375 0x0000000000000000ULL,
1376 0xFD00000000000000ULL,
1377 0xFDFD000000000000ULL,
1378 0xFDFDFD0000000000ULL,
1379 0xFDFDFDFD00000000ULL,
1380 0xFDFDFDFDFD000000ULL,
1381 0xFDFDFDFDFDFD0000ULL,
1382 0xFDFDFDFDFDFDFD00ULL
1383 },
1384 {
1385 0xFD00000000000000ULL,
1386 0xFDFD000000000000ULL,
1387 0xFDFDFD0000000000ULL,
1388 0xFDFDFDFD00000000ULL,
1389 0xFDFDFDFDFD000000ULL,
1390 0xFDFDFDFDFDFD0000ULL,
1391 0xFDFDFDFDFDFDFD00ULL,
1392 0xFDFDFDFDFDFDFDFDULL
1393 },
1394 {
1395 0xFDFD000000000000ULL,
1396 0xFDFDFD0000000000ULL,
1397 0xFDFDFDFD00000000ULL,
1398 0xFDFDFDFDFD000000ULL,
1399 0xFDFDFDFDFDFD0000ULL,
1400 0xFDFDFDFDFDFDFD00ULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL
1403 },
1404 {
1405 0xFDFDFD0000000000ULL,
1406 0xFDFDFDFD00000000ULL,
1407 0xFDFDFDFDFD000000ULL,
1408 0xFDFDFDFDFDFD0000ULL,
1409 0xFDFDFDFDFDFDFD00ULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL
1413 },
1414 {
1415 0xFDFDFDFD00000000ULL,
1416 0xFDFDFDFDFD000000ULL,
1417 0xFDFDFDFDFDFD0000ULL,
1418 0xFDFDFDFDFDFDFD00ULL,
1419 0xFDFDFDFDFDFDFDFDULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0xFDFDFDFDFDFDFDFDULL,
1422 0xFDFDFDFDFDFDFDFDULL
1423 },
1424 {
1425 0xFDFDFDFDFD000000ULL,
1426 0xFDFDFDFDFDFD0000ULL,
1427 0xFDFDFDFDFDFDFD00ULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL,
1432 0xFDFDFDFDFDFDFDFDULL
1433 },
1434 {
1435 0xFDFDFDFDFDFD0000ULL,
1436 0xFDFDFDFDFDFDFD00ULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL,
1442 0xFDFDFDFDFDFDFDFDULL
1443 },
1444 {
1445 0xFDFDFDFDFDFDFD00ULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL,
1451 0xFDFDFDFDFDFDFDFDULL,
1452 0xFDFDFDFDFDFDFDFDULL
1453 },
1454 {
1455 0xFDFDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL,
1461 0xFDFDFDFDFDFDFDFDULL,
1462 0xFDFDFDFDFDFDFDFDULL
1463 }
1464 },
1465 {
1466 {
1467 0x0000000000000000ULL,
1468 0x0000000000000000ULL,
1469 0x0000000000000000ULL,
1470 0x0000000000000000ULL,
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL
1475 },
1476 {
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL,
1484 0x00000000000000FDULL
1485 },
1486 {
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x0000000000000000ULL,
1493 0x00000000000000FDULL,
1494 0x000000000000FDFDULL
1495 },
1496 {
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x0000000000000000ULL,
1502 0x00000000000000FDULL,
1503 0x000000000000FDFDULL,
1504 0x0000000000FDFDFDULL
1505 },
1506 {
1507 0x0000000000000000ULL,
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x0000000000000000ULL,
1511 0x00000000000000FDULL,
1512 0x000000000000FDFDULL,
1513 0x0000000000FDFDFDULL,
1514 0x00000000FDFDFDFDULL
1515 },
1516 {
1517 0x0000000000000000ULL,
1518 0x0000000000000000ULL,
1519 0x0000000000000000ULL,
1520 0x00000000000000FDULL,
1521 0x000000000000FDFDULL,
1522 0x0000000000FDFDFDULL,
1523 0x00000000FDFDFDFDULL,
1524 0x000000FDFDFDFDFDULL
1525 },
1526 {
1527 0x0000000000000000ULL,
1528 0x0000000000000000ULL,
1529 0x00000000000000FDULL,
1530 0x000000000000FDFDULL,
1531 0x0000000000FDFDFDULL,
1532 0x00000000FDFDFDFDULL,
1533 0x000000FDFDFDFDFDULL,
1534 0x0000FDFDFDFDFDFDULL
1535 },
1536 {
1537 0x0000000000000000ULL,
1538 0x00000000000000FDULL,
1539 0x000000000000FDFDULL,
1540 0x0000000000FDFDFDULL,
1541 0x00000000FDFDFDFDULL,
1542 0x000000FDFDFDFDFDULL,
1543 0x0000FDFDFDFDFDFDULL,
1544 0x00FDFDFDFDFDFDFDULL
1545 },
1546 {
1547 0x00000000000000FDULL,
1548 0x000000000000FDFDULL,
1549 0x0000000000FDFDFDULL,
1550 0x00000000FDFDFDFDULL,
1551 0x000000FDFDFDFDFDULL,
1552 0x0000FDFDFDFDFDFDULL,
1553 0x00FDFDFDFDFDFDFDULL,
1554 0xFDFDFDFDFDFDFDFDULL
1555 },
1556 {
1557 0x000000000000FDFDULL,
1558 0x0000000000FDFDFDULL,
1559 0x00000000FDFDFDFDULL,
1560 0x000000FDFDFDFDFDULL,
1561 0x0000FDFDFDFDFDFDULL,
1562 0x00FDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL
1565 },
1566 {
1567 0x0000000000FDFDFDULL,
1568 0x00000000FDFDFDFDULL,
1569 0x000000FDFDFDFDFDULL,
1570 0x0000FDFDFDFDFDFDULL,
1571 0x00FDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL
1575 },
1576 {
1577 0x00000000FDFDFDFDULL,
1578 0x000000FDFDFDFDFDULL,
1579 0x0000FDFDFDFDFDFDULL,
1580 0x00FDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL,
1584 0xFDFDFDFDFDFDFDFDULL
1585 },
1586 {
1587 0x000000FDFDFDFDFDULL,
1588 0x0000FDFDFDFDFDFDULL,
1589 0x00FDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL,
1594 0xFDFDFDFDFDFDFDFDULL
1595 },
1596 {
1597 0x0000FDFDFDFDFDFDULL,
1598 0x00FDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL,
1604 0xFDFDFDFDFDFDFDFDULL
1605 },
1606 {
1607 0x00FDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL,
1613 0xFDFDFDFDFDFDFDFDULL,
1614 0xFDFDFDFDFDFDFDFDULL
1615 },
1616 {
1617 0xFDFDFDFDFDFDFDFDULL,
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL,
1623 0xFDFDFDFDFDFDFDFDULL,
1624 0xFDFDFDFDFDFDFDFDULL
1625 }
1626 }
1627 };
1628
1629 int32_t black_opening_count=0;
1630 int32_t black_opening_x,black_opening_y;
1631 int32_t black_opening_shape;
1632
1633 460 int32_t choose_opening_shape()
1634 {
1635 // First, count how many bits are set
1636 460 int32_t numBits=0;
1637 int32_t bitCounter;
1638
1639
2/2
✓ Branch 0 taken 2300 times.
✓ Branch 1 taken 460 times.
2760 for(int32_t i=0; i<bosMAX; i++)
1640 {
1641
2/2
✓ Branch 0 taken 1624 times.
✓ Branch 1 taken 676 times.
2300 if(COOLSCROLL&(1<<i))
1642 676 numBits++;
1643 2300 }
1644
1645 // Shouldn't happen...
1646
1/2
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
460 if(numBits==0)
1647 return bosCIRCLE;
1648
1649 // Pick a bit
1650 460 bitCounter=zc_rand()%numBits+1;
1651
1652
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 26 times.
698 for(int32_t i=0; i<bosMAX; i++)
1653 {
1654 // If this bit is set, decrement the bit counter
1655
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 590 times.
672 if(COOLSCROLL&(1<<i))
1656 590 bitCounter--;
1657
1658 // When the counter hits 0, return a value based on
1659 // which bit it stopped on.
1660 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1661
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 238 times.
672 if(bitCounter==0)
1662 434 return i;
1663 238 }
1664
1665 // Shouldn't be necessary, but the compiler might complain, at least
1666 26 return bosCIRCLE;
1667 460 }
1668
1669 140 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1670 {
1671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1672
1673 140 int32_t w=256, h=224;
1674 140 int32_t blockrows=28, blockcolumns=32;
1675 140 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1676
1677
2/2
✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 140 times.
4060 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1678 {
1679
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 3920 times.
129360 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1680 {
1681
2/2
✓ Branch 0 taken 67190 times.
✓ Branch 1 taken 58250 times.
125440 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1682 125440 }
1683 3920 }
1684
1685 140 black_opening_count = 66;
1686 140 black_opening_x = x;
1687 140 black_opening_y = y;
1688 140 lensclk = 0;
1689 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1690
1691
1692
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(black_opening_shape == bosFADEBLACK)
1693 {
1694 refreshTints();
1695 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1696 }
1697
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(wait)
1698 {
1699 FFCore.warpScriptCheck();
1700 for(int32_t i=0; i<66; i++)
1701 {
1702 draw_screen(tmpscr);
1703 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1704 syskeys();
1705 advanceframe(true);
1706
1707 if(Quit)
1708 {
1709 break;
1710 }
1711 }
1712 }
1713 140 }
1714
1715 320 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1716 {
1717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1718
1719 320 int32_t w=256, h=224;
1720 320 int32_t blockrows=28, blockcolumns=32;
1721 320 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1722
1723
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 320 times.
9280 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1724 {
1725
2/2
✓ Branch 0 taken 286720 times.
✓ Branch 1 taken 8960 times.
295680 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1726 {
1727
2/2
✓ Branch 0 taken 137730 times.
✓ Branch 1 taken 148990 times.
286720 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1728 286720 }
1729 8960 }
1730
1731 320 black_opening_count = -66;
1732 320 black_opening_x = x;
1733 320 black_opening_y = y;
1734 320 lensclk = 0;
1735
1/2
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
320 if(black_opening_shape == bosFADEBLACK)
1736 {
1737 refreshTints();
1738 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1739 }
1740
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 210 times.
320 if(wait)
1741 {
1742 210 FFCore.warpScriptCheck();
1743
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 13860 times.
14070 for(int32_t i=0; i<66; i++)
1744 {
1745 13860 draw_screen(tmpscr);
1746 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1747 13860 syskeys();
1748 13860 advanceframe(true);
1749
1750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13860 times.
13860 if(Quit)
1751 {
1752 break;
1753 }
1754 13860 }
1755 210 }
1756 320 }
1757
1758 30360 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1759 {
1760 30360 clear_to_color(tmp_scr,BLACK);
1761 30360 int32_t w=256, h=224;
1762
1763
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27192 times.
30360 switch(black_opening_shape)
1764 {
1765 case bosOVAL:
1766 {
1767 858 double new_w=(w/2)+abs(w/2-x);
1768 858 double new_h=(h/2)+abs(h/2-y);
1769 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1770 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1771 858 break;
1772 }
1773
1774 case bosTRIANGLE:
1775 {
1776 660 double new_w=(w/2)+abs(w/2-x);
1777 660 double new_h=(h/2)+abs(h/2-y);
1778 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1779 660 double P2= (PI/2);
1780 660 double P23=(2*PI/3);
1781 660 double P43=(4*PI/3);
1782 660 double Pa= (-4*PI*a/(3*max_a));
1783 660 double angle=P2+Pa;
1784 660 double a0=angle;
1785 660 double a2=angle+P23;
1786 660 double a4=angle+P43;
1787 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1788 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1789 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1790 0);
1791 660 break;
1792 }
1793
1794 case bosSMAS:
1795 {
1796
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1797
1798
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1799 {
1800
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1801 {
1802 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1803
1804
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1805 {
1806 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1807
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1808 11827200 [linerow];
1809 11827200 ++triangleline;
1810
1811
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1812 {
1813 1478400 }
1814 11827200 }
1815 369600 }
1816 46200 }
1817
1818 1650 break;
1819 }
1820
1821 case bosFADEBLACK:
1822 {
1823 if(black_opening_count<0)
1824 {
1825 black_fade(zc_min(-black_opening_count,63));
1826 }
1827 else if(black_opening_count>0)
1828 {
1829 black_fade(63-zc_max(black_opening_count-3,0));
1830 }
1831 else black_fade(0);
1832 return; //no blitting from tmp_scr!
1833 }
1834
1835 27192 case bosCIRCLE:
1836 default:
1837 {
1838 27192 double new_w=(w/2)+abs(w/2-x);
1839 27192 double new_h=(h/2)+abs(h/2-y);
1840 27192 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1841 //circlefill(tmp_scr,x,y,a<<3,0);
1842 27192 circlefill(tmp_scr,x,y,r,0);
1843 27192 break;
1844 }
1845 }
1846
1847 30360 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1848 30360 }
1849
1850
1851 void black_fade(int32_t fadeamnt)
1852 {
1853 for(int32_t i=0; i < 0xEF; i++)
1854 {
1855 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1856 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1857 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1858 }
1859
1860 refreshpal = true;
1861 }
1862
1863 //----------------------------------------------------------------
1864
1865 12305194 bool item_disabled(int32_t item) //is this item disabled?
1866 {
1867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12305194 times.
12305194 return (item>=0 && game->items_off[item] != 0);
1868 }
1869
1870 3474685 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1871 {
1872
2/2
✓ Branch 0 taken 20760 times.
✓ Branch 1 taken 3453925 times.
3474685 if(current_item(item_type, true) >=item)
1873 {
1874 20760 return true;
1875 }
1876
1877 3453925 return false;
1878 3474685 }
1879
1880 16378593 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1881 {
1882
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2608118 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1831366 times.
✓ Branch 6 taken 8996686 times.
✓ Branch 7 taken 2923636 times.
✓ Branch 8 taken 18787 times.
16378593 switch(item_type)
1883 {
1884 case itype_bomb:
1885 case itype_sbomb:
1886 {
1887 int32_t itemid = getItemID(itemsbuf, item_type, it);
1888
1889 if(itemid == -1)
1890 return false;
1891
1892 return (game->get_item(itemid));
1893 }
1894
1895 case itype_clock:
1896 {
1897 2608118 int32_t itemid = getItemID(itemsbuf, item_type, it);
1898
1899
2/4
✓ Branch 0 taken 2608118 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2608118 times.
✗ Branch 3 not taken.
2608118 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1900 return (game->get_item(itemid));
1901 2608118 return Hero.getClock()?1:0;
1902 }
1903
1904 case itype_key:
1905 return (game->get_keys()>0);
1906
1907 case itype_magiccontainer:
1908 return (game->get_maxmagic()>=game->get_mp_per_block());
1909
1910 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1911 {
1912
1/3
✓ Branch 0 taken 1831366 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1831366 switch(it)
1913 {
1914 case -2:
1915 {
1916 for(int32_t i=0; i<MAXLEVELS; i++)
1917 {
1918 if(game->lvlitems[i]&liTRIFORCE)
1919 {
1920 return true;
1921 }
1922 }
1923
1924 return false;
1925 }
1926
1927 case -1:
1928 return (game->lvlitems[dlevel]&liTRIFORCE);
1929
1930 default:
1931
2/4
✓ Branch 0 taken 1831366 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1831366 times.
1831366 if(it>=0&&it<MAXLEVELS)
1932 {
1933 1831366 return (game->lvlitems[it]&liTRIFORCE);
1934 }
1935
1936 break;
1937 }
1938
1939 return 0;
1940 }
1941
1942 case itype_map: //it: -2=any, -1=current level, other=that level
1943 {
1944
1/3
✓ Branch 0 taken 8996686 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
8996686 switch(it)
1945 {
1946 case -2:
1947 {
1948 for(int32_t i=0; i<MAXLEVELS; i++)
1949 {
1950 if(game->lvlitems[i]&liMAP)
1951 {
1952 return true;
1953 }
1954 }
1955
1956 return false;
1957 }
1958
1959 case -1:
1960 return (game->lvlitems[dlevel]&liMAP)!=0;
1961
1962 default:
1963
2/4
✓ Branch 0 taken 8996686 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8996686 times.
8996686 if(it>=0&&it<MAXLEVELS)
1964 {
1965 8996686 return (game->lvlitems[it]&liMAP)!=0;
1966 }
1967
1968 break;
1969 }
1970
1971 return 0;
1972 }
1973
1974 case itype_compass: //it: -2=any, -1=current level, other=that level
1975 {
1976
1/3
✓ Branch 0 taken 2923636 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2923636 switch(it)
1977 {
1978 case -2:
1979 {
1980 for(int32_t i=0; i<MAXLEVELS; i++)
1981 {
1982 if(game->lvlitems[i]&liCOMPASS)
1983 {
1984 return true;
1985 }
1986 }
1987
1988 return false;
1989 }
1990
1991 case -1:
1992 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
1993
1994 default:
1995
2/4
✓ Branch 0 taken 2923636 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2923636 times.
✗ Branch 3 not taken.
2923636 if(it>=0&&it<MAXLEVELS)
1996 {
1997 2923636 return (game->lvlitems[it]&liCOMPASS)!=0;
1998 }
1999
2000 break;
2001 }
2002 return 0;
2003 }
2004
2005 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2006 {
2007
1/3
✓ Branch 0 taken 18787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
18787 switch(it)
2008 {
2009 case -2:
2010 {
2011 for(int32_t i=0; i<MAXLEVELS; i++)
2012 {
2013 if(game->lvlitems[i]&liBOSSKEY)
2014 {
2015 return true;
2016 }
2017 }
2018
2019 return false;
2020 }
2021
2022 case -1:
2023 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2024
2025 default:
2026
2/4
✓ Branch 0 taken 18787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18787 times.
18787 if(it>=0&&it<MAXLEVELS)
2027 {
2028 18787 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2029 }
2030 break;
2031 }
2032 return 0;
2033 }
2034
2035 default:
2036 //it=(1<<(it-1));
2037 /*if (item_type>=itype_max)
2038 {
2039 system_pal();
2040 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2041 game_pal();
2042
2043 return false;
2044 }*/
2045 int32_t itemid = getItemID(itemsbuf, item_type, it);
2046
2047 if(itemid == -1)
2048 return false;
2049
2050 return game->get_item(itemid);
2051 }
2052 16378593 }
2053
2054
2055 45053100 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2056 {
2057
9/9
✓ Branch 0 taken 2608118 times.
✓ Branch 1 taken 24188156 times.
✓ Branch 2 taken 2608118 times.
✓ Branch 3 taken 2608118 times.
✓ Branch 4 taken 2608118 times.
✓ Branch 5 taken 2608118 times.
✓ Branch 6 taken 2608118 times.
✓ Branch 7 taken 2608118 times.
✓ Branch 8 taken 2608118 times.
45053100 switch(item_type)
2058 {
2059 case itype_clock:
2060 {
2061 2608118 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2062
2063
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2608118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2608118 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2064 return itemsbuf[maxid].fam_type;
2065
2066 2608118 return has_item(itype_clock,1) ? 1 : 0;
2067 }
2068
2069 case itype_key:
2070 2608118 return game->get_keys();
2071
2072 case itype_lkey:
2073 2608118 return game->lvlkeys[get_dlevel()];
2074
2075 case itype_magiccontainer:
2076 2608118 return game->get_maxmagic()/game->get_mp_per_block();
2077
2078 case itype_triforcepiece:
2079 {
2080 2608118 int32_t count=0;
2081
2082
2/2
✓ Branch 0 taken 1335356416 times.
✓ Branch 1 taken 2608118 times.
1337964534 for(int32_t i=0; i<MAXLEVELS; i++)
2083 {
2084 1335356416 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2085 1335356416 }
2086
2087 2608118 return count;
2088 }
2089
2090 case itype_map:
2091 {
2092 2608118 int32_t count=0;
2093
2094
2/2
✓ Branch 0 taken 1335356416 times.
✓ Branch 1 taken 2608118 times.
1337964534 for(int32_t i=0; i<MAXLEVELS; i++)
2095 {
2096 1335356416 count+=(game->lvlitems[i]&liMAP)?1:0;
2097 1335356416 }
2098
2099 2608118 return count;
2100 }
2101
2102 case itype_compass:
2103 {
2104 2608118 int32_t count=0;
2105
2106
2/2
✓ Branch 0 taken 1335356416 times.
✓ Branch 1 taken 2608118 times.
1337964534 for(int32_t i=0; i<MAXLEVELS; i++)
2107 {
2108 1335356416 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2109 1335356416 }
2110
2111 2608118 return count;
2112 }
2113
2114 case itype_bosskey:
2115 {
2116 2608118 int32_t count=0;
2117
2118
2/2
✓ Branch 0 taken 1335356416 times.
✓ Branch 1 taken 2608118 times.
1337964534 for(int32_t i=0; i<MAXLEVELS; i++)
2119 {
2120 1335356416 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2121 1335356416 }
2122
2123 2608118 return count;
2124 }
2125
2126 default:
2127 24188156 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2128
2129
2/2
✓ Branch 0 taken 5443342 times.
✓ Branch 1 taken 18744814 times.
24188156 if(maxid == -1)
2130 18744814 return 0;
2131
2132 5443342 return itemsbuf[maxid].fam_type;
2133 }
2134 45053100 }
2135
2136 41578415 int32_t current_item(int32_t item_type) //item currently being used
2137 {
2138 41578415 return current_item(item_type, true);
2139 }
2140
2141 24 std::map<int32_t, int32_t> itemcache;
2142
2143 // Not actually used by anything at the moment...
2144 void removeFromItemCache(int32_t itemid)
2145 {
2146 itemcache.erase(itemid);
2147 }
2148
2149 12374 void flushItemCache()
2150 {
2151 12374 itemcache.clear();
2152
2153 //also fix the active subscreen if items were deleted -DD
2154
1/2
✓ Branch 0 taken 12374 times.
✗ Branch 1 not taken.
12374 if(game != NULL)
2155 {
2156 12374 verifyBothWeapons();
2157 12374 load_Sitems(&QMisc);
2158 12374 }
2159 12374 }
2160
2161 // This is used often, so it should be as direct as possible.
2162 1464645236 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2163 {
2164
2/2
✓ Branch 0 taken 1429018932 times.
✓ Branch 1 taken 35626304 times.
1464645236 if(jinx_check)
2165 {
2166
4/4
✓ Branch 0 taken 21561432 times.
✓ Branch 1 taken 14064872 times.
✓ Branch 2 taken 18154406 times.
✓ Branch 3 taken 3407026 times.
35626304 if(!(HeroSwordClk() || HeroItemClk()))
2167 18154406 jinx_check = false; //not jinxed
2168 35626304 }
2169
4/4
✓ Branch 0 taken 1453251756 times.
✓ Branch 1 taken 11393480 times.
✓ Branch 2 taken 17347370 times.
✓ Branch 3 taken 1435904386 times.
1464645236 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2170 {
2171 1435904386 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2172
2173
2/2
✓ Branch 0 taken 1429587359 times.
✓ Branch 1 taken 6317027 times.
1435904386 if(res != itemcache.end())
2174 1429587359 return res->second;
2175 6317027 }
2176
2177 35057877 int32_t result = -1;
2178 35057877 int32_t highestlevel = -1;
2179
2180
2/2
✓ Branch 0 taken 8974816512 times.
✓ Branch 1 taken 35057877 times.
9009874389 for(int32_t i=0; i<MAXITEMS; i++)
2181 {
2182
5/6
✓ Branch 0 taken 739517576 times.
✓ Branch 1 taken 8235298936 times.
✓ Branch 2 taken 11967593 times.
✓ Branch 3 taken 727549983 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11967593 times.
8974816512 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2183 {
2184
4/4
✓ Branch 0 taken 3040690 times.
✓ Branch 1 taken 8926903 times.
✓ Branch 2 taken 917460 times.
✓ Branch 3 taken 11050133 times.
11967593 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2185 {
2186 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2187
2/2
✓ Branch 0 taken 11050025 times.
✓ Branch 1 taken 108 times.
11050133 if(!checkmagiccost(i))
2188 {
2189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2190 }
2191 11050025 }
2192
6/6
✓ Branch 0 taken 10137753 times.
✓ Branch 1 taken 1829732 times.
✓ Branch 2 taken 180198 times.
✓ Branch 3 taken 1649534 times.
✓ Branch 4 taken 1165339 times.
✓ Branch 5 taken 664393 times.
11967485 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2193 {
2194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 664393 times.
664393 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2195 664393 continue;
2196 }
2197
2198
2/2
✓ Branch 0 taken 177180 times.
✓ Branch 1 taken 11125912 times.
11303092 if(itemsbuf[i].fam_type >= highestlevel)
2199 {
2200 11125912 highestlevel = itemsbuf[i].fam_type;
2201 11125912 result=i;
2202 11125912 }
2203 11303092 }
2204 8974152011 }
2205
2206
2/2
✓ Branch 0 taken 17471898 times.
✓ Branch 1 taken 17585979 times.
35057877 if(!jinx_check) //Can't cache jinx_check results
2207 17585979 itemcache[itemtype] = result;
2208 35057877 return result;
2209 1464645236 }
2210
2211 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2212 1447410644 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2213 {
2214 1447410644 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2215
2/2
✓ Branch 0 taken 18391712 times.
✓ Branch 1 taken 1429018932 times.
1447410644 if(!jinx_check) //If not already a jinx-immune-only check...
2216 {
2217 //And the player IS jinxed...
2218
4/4
✓ Branch 0 taken 1415141704 times.
✓ Branch 1 taken 13877228 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 1411784340 times.
1429018932 if(HeroSwordClk() || HeroItemClk())
2219 {
2220 //Then do a jinx-immune-only check here
2221 17234592 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2222 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2223 //Should NOT need a compat rule, as this should always return -1 in old quests.
2224
2/2
✓ Branch 0 taken 799717 times.
✓ Branch 1 taken 16434875 times.
17234592 if(ret2 > -1) return ret2;
2225 16434875 }
2226 1428219215 }
2227 1446610927 return ret;
2228 1447410644 }
2229 10752615 int32_t current_item_power(int32_t itemtype)
2230 {
2231 10752615 int32_t result = current_item_id(itemtype,true);
2232
2/2
✓ Branch 0 taken 7521224 times.
✓ Branch 1 taken 3231391 times.
10752615 return (result<0) ? 0 : itemsbuf[result].power;
2233 }
2234
2235 5 int32_t heart_container_id()
2236 {
2237
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 for(int32_t i=0; i<MAXITEMS; i++)
2238 {
2239
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 140 times.
145 if(itemsbuf[i].family == itype_heartcontainer)
2240 {
2241 5 return i;
2242 }
2243 140 }
2244 return -1;
2245 5 }
2246
2247 2608118 int32_t item_tile_mod()
2248 {
2249 2608118 int32_t tile=0;
2250
2251
2/2
✓ Branch 0 taken 495610 times.
✓ Branch 1 taken 2112508 times.
2608118 if(game->get_bombs())
2252 {
2253 2112508 int32_t itemid = current_item_id(itype_bomb,false);
2254
3/4
✓ Branch 0 taken 2031449 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2031449 times.
2112508 if(itemid > -1 && checkbunny(itemid))
2255 2031449 tile+=itemsbuf[itemid].ltm;
2256 2112508 }
2257
2258
2/2
✓ Branch 0 taken 2169329 times.
✓ Branch 1 taken 438789 times.
2608118 if(game->get_sbombs())
2259 {
2260 438789 int32_t itemid = current_item_id(itype_sbomb,false);
2261
3/4
✓ Branch 0 taken 437361 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 437361 times.
438789 if(itemid > -1 && checkbunny(itemid))
2262 437361 tile+=itemsbuf[itemid].ltm;
2263 438789 }
2264
2265
2/2
✓ Branch 0 taken 2530849 times.
✓ Branch 1 taken 77269 times.
2608118 if(current_item(itype_clock))
2266 {
2267 77269 int32_t itemid =
2268
1/2
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
77269 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2269 ? iClock
2270 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2271
2/4
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77269 times.
77269 if(itemid > -1 && checkbunny(itemid))
2272 77269 tile+=itemsbuf[itemid].ltm;
2273 77269 }
2274
2275
2/2
✓ Branch 0 taken 2015850 times.
✓ Branch 1 taken 592268 times.
2608118 if(current_item(itype_key))
2276 {
2277 592268 int32_t itemid =
2278
1/2
✓ Branch 0 taken 592268 times.
✗ Branch 1 not taken.
592268 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2279 ? iKey
2280 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2281
2/4
✓ Branch 0 taken 592268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 592268 times.
592268 if(itemid > -1 && checkbunny(itemid))
2282 592268 tile+=itemsbuf[itemid].ltm;
2283 592268 }
2284
2285
2/2
✓ Branch 0 taken 2474557 times.
✓ Branch 1 taken 133561 times.
2608118 if(current_item(itype_lkey))
2286 {
2287 133561 int32_t itemid =
2288
2/2
✓ Branch 0 taken 132651 times.
✓ Branch 1 taken 910 times.
133561 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2289 ? iLevelKey
2290 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2291
2/4
✓ Branch 0 taken 133561 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133561 times.
133561 if(itemid > -1 && checkbunny(itemid))
2292 133561 tile+=itemsbuf[itemid].ltm;
2293 133561 }
2294
2295
2/2
✓ Branch 0 taken 402164 times.
✓ Branch 1 taken 2205954 times.
2608118 if(current_item(itype_map))
2296 {
2297 2205954 int32_t itemid =
2298
2/2
✓ Branch 0 taken 2205168 times.
✓ Branch 1 taken 786 times.
2205954 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2299 ? iMap
2300 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2301
2/4
✓ Branch 0 taken 2205954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2205954 times.
2205954 if(itemid > -1 && checkbunny(itemid))
2302 2205954 tile+=itemsbuf[itemid].ltm;
2303 2205954 }
2304
2305
2/2
✓ Branch 0 taken 319461 times.
✓ Branch 1 taken 2288657 times.
2608118 if(current_item(itype_compass))
2306 {
2307 2288657 int32_t itemid =
2308
2/2
✓ Branch 0 taken 2207598 times.
✓ Branch 1 taken 81059 times.
2288657 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2309 ? iCompass
2310 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2311
2/4
✓ Branch 0 taken 2288657 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2288657 times.
2288657 if(itemid > -1 && checkbunny(itemid))
2312 2288657 tile+=itemsbuf[itemid].ltm;
2313 2288657 }
2314
2315
2/2
✓ Branch 0 taken 797756 times.
✓ Branch 1 taken 1810362 times.
2608118 if(current_item(itype_bosskey))
2316 {
2317 1810362 int32_t itemid =
2318
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2319 ? iBossKey
2320 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2321
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2322 1810362 tile+=itemsbuf[itemid].ltm;
2323 1810362 }
2324
2325
2/2
✓ Branch 0 taken 2084098 times.
✓ Branch 1 taken 524020 times.
2608118 if(current_item(itype_magiccontainer))
2326 {
2327 524020 int32_t itemid =
2328
2/2
✓ Branch 0 taken 442175 times.
✓ Branch 1 taken 81845 times.
524020 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2329 ? iMagicC
2330 81845 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2331
2/4
✓ Branch 0 taken 524020 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 524020 times.
524020 if(itemid > -1 && checkbunny(itemid))
2332 524020 tile+=itemsbuf[itemid].ltm;
2333 524020 }
2334
2335
2/2
✓ Branch 0 taken 631531 times.
✓ Branch 1 taken 1976587 times.
2608118 if(current_item(itype_triforcepiece))
2336 {
2337 1976587 int32_t itemid =
2338
1/2
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
1976587 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2339 ? iTriforce
2340 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2341
2/4
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1976587 times.
1976587 if(itemid > -1 && checkbunny(itemid))
2342 1976587 tile+=itemsbuf[itemid].ltm;
2343 1976587 }
2344
2345
2/2
✓ Branch 0 taken 2608118 times.
✓ Branch 1 taken 1335356416 times.
1337964534 for(int32_t i=0; i<itype_max; i++)
2346 {
2347
2/2
✓ Branch 0 taken 1284996096 times.
✓ Branch 1 taken 50360320 times.
1335356416 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2348 {
2349
2/2
✓ Branch 0 taken 983600 times.
✓ Branch 1 taken 49376720 times.
50360320 switch(i)
2350 {
2351 case itype_bomb:
2352 case itype_sbomb:
2353 case itype_clock:
2354 case itype_key:
2355 case itype_lkey:
2356 case itype_map:
2357 case itype_compass:
2358 case itype_bosskey:
2359 case itype_magiccontainer:
2360 case itype_triforcepiece:
2361 983600 continue; //already handled
2362 }
2363 49376720 }
2364 1334372816 int32_t itemid = current_item_id(i,false);
2365
2/2
✓ Branch 0 taken 1331764698 times.
✓ Branch 1 taken 2608118 times.
1334372816 if(i == itype_shield)
2366 2608118 itemid = getCurrentShield(false);
2367
2368
3/4
✓ Branch 0 taken 37605395 times.
✓ Branch 1 taken 1296767421 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37605395 times.
1334372816 if(itemid < 0 || !checkbunny(itemid))
2369 1296767421 continue;
2370
2371 37605395 itemdata const& itm = itemsbuf[itemid];
2372
2373
2/2
✓ Branch 0 taken 35286376 times.
✓ Branch 1 taken 2319019 times.
37605395 switch(itm.family)
2374 {
2375 case itype_shield:
2376
1/2
✓ Branch 0 taken 2319019 times.
✗ Branch 1 not taken.
2319019 if(itm.flags & ITEM_FLAG9) //active shield
2377 {
2378 if(!usingActiveShield(itemid))
2379 {
2380 tile+=itm.misc6; //'Inactive PTM'
2381 continue;
2382 }
2383 }
2384 2319019 break;
2385 }
2386
2387 37605395 tile+=itm.ltm;
2388 37605395 }
2389
2390 2608118 return tile;
2391 }
2392
2393 2608118 int32_t bunny_tile_mod()
2394 {
2395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2608118 times.
2608118 if(Hero.BunnyClock())
2396 {
2397 return game->get_bunny_ltm();
2398 }
2399 2608118 return 0;
2400 2608118 }
2401
2402 // Hints are drawn on a separate layer to combo reveals.
2403 8618 void draw_lens_under(BITMAP *dest, bool layer)
2404 {
2405 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2406 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2407 //Lens flag 3: Don't show armos/chest/dive items
2408 //Lens flag 4: Show Raft Paths
2409 //Lens flag 5: Show Invisible Enemies
2410
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8618 times.
✓ Branch 2 taken 4309 times.
✓ Branch 3 taken 4309 times.
8618 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2411
2412 8618 int32_t strike_hint_table[11]=
2413 {
2414 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2415 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2416 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2417 };
2418
2419 // int32_t page = tmpscr->cpage;
2420 {
2421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8618 times.
8618 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2422 // int32_t temptimer=0;
2423 8618 int32_t tempitem, tempweapon=0;
2424 8618 strike_hint=strike_hint_table[strike_hint_counter];
2425
2426
2/2
✓ Branch 0 taken 8358 times.
✓ Branch 1 taken 260 times.
8618 if(strike_hint_timer>32)
2427 {
2428 260 strike_hint_timer=0;
2429 260 strike_hint_counter=((strike_hint_counter+1)%11);
2430 260 }
2431
2432 8618 ++strike_hint_timer;
2433
2434
2/2
✓ Branch 0 taken 1516768 times.
✓ Branch 1 taken 8618 times.
1525386 for(int32_t i=0; i<176; i++)
2435 {
2436 1516768 int32_t x = (i & 15) << 4;
2437 1516768 int32_t y = (i & 0xF0) + playing_field_offset;
2438 1516768 int32_t tempitemx=-16, tempitemy=-16;
2439 1516768 int32_t tempweaponx=-16, tempweapony=-16;
2440
2441
2/2
✓ Branch 0 taken 3033536 times.
✓ Branch 1 taken 1516768 times.
4550304 for(int32_t iter=0; iter<2; ++iter)
2442 {
2443 3033536 int32_t checkflag=0;
2444
2445
2/2
✓ Branch 0 taken 1516768 times.
✓ Branch 1 taken 1516768 times.
3033536 if(iter==0)
2446 {
2447 1516768 checkflag=combobuf[tmpscr->data[i]].flag;
2448 1516768 }
2449 else
2450 {
2451 1516768 checkflag=tmpscr->sflag[i];
2452 }
2453
2454
2/2
✓ Branch 0 taken 3033152 times.
✓ Branch 1 taken 384 times.
3033536 if(checkflag==mfSTRIKE)
2455 {
2456
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 192 times.
384 if(!hints)
2457 {
2458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2459 192 }
2460 else
2461 {
2462 192 checkflag = strike_hint;
2463 }
2464 384 }
2465
2466
19/36
✓ Branch 0 taken 2997346 times.
✓ Branch 1 taken 2638 times.
✓ Branch 2 taken 2016 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28392 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 118 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 192 times.
3033536 switch(checkflag)
2467 {
2468 case 0:
2469 case mfZELDA:
2470 case mfPUSHED:
2471 case mfENEMY0:
2472 case mfENEMY1:
2473 case mfENEMY2:
2474 case mfENEMY3:
2475 case mfENEMY4:
2476 case mfENEMY5:
2477 case mfENEMY6:
2478 case mfENEMY7:
2479 case mfENEMY8:
2480 case mfENEMY9:
2481 case mfSINGLE:
2482 case mfSINGLE16:
2483 case mfNOENEMY:
2484 case mfTRAP_H:
2485 case mfTRAP_V:
2486 case mfTRAP_4:
2487 case mfTRAP_LR:
2488 case mfTRAP_UD:
2489 case mfNOGROUNDENEMY:
2490 case mfNOBLOCKS:
2491 case mfSCRIPT1:
2492 case mfSCRIPT2:
2493 case mfSCRIPT3:
2494 case mfSCRIPT4:
2495 case mfSCRIPT5:
2496 case mfSCRIPT6:
2497 case mfSCRIPT7:
2498 case mfSCRIPT8:
2499 case mfSCRIPT9:
2500 case mfSCRIPT10:
2501 case mfSCRIPT11:
2502 case mfSCRIPT12:
2503 case mfSCRIPT13:
2504 case mfSCRIPT14:
2505 case mfSCRIPT15:
2506 case mfSCRIPT16:
2507 case mfSCRIPT17:
2508 case mfSCRIPT18:
2509 case mfSCRIPT19:
2510 case mfSCRIPT20:
2511 case mfPITHOLE:
2512 case mfPITFALLFLOOR:
2513 case mfLAVA:
2514 case mfICE:
2515 case mfICEDAMAGE:
2516 case mfDAMAGE1:
2517 case mfDAMAGE2:
2518 case mfDAMAGE4:
2519 case mfDAMAGE8:
2520 case mfDAMAGE16:
2521 case mfDAMAGE32:
2522 case mfFREEZEALL:
2523 case mfFREZEALLANSFFCS:
2524 case mfFREEZEFFCSOLY:
2525 case mfSCRITPTW1TRIG:
2526 case mfSCRITPTW2TRIG:
2527 case mfSCRITPTW3TRIG:
2528 case mfSCRITPTW4TRIG:
2529 case mfSCRITPTW5TRIG:
2530 case mfSCRITPTW6TRIG:
2531 case mfSCRITPTW7TRIG:
2532 case mfSCRITPTW8TRIG:
2533 case mfSCRITPTW9TRIG:
2534 case mfSCRITPTW10TRIG:
2535 case mfTROWEL:
2536 case mfTROWELNEXT:
2537 case mfTROWELSPECIALITEM:
2538 case mfSLASHPOT:
2539 case mfLIFTPOT:
2540 case mfLIFTORSLASH:
2541 case mfLIFTROCK:
2542 case mfLIFTROCKHEAVY:
2543 case mfDROPITEM:
2544 case mfSPECIALITEM:
2545 case mfDROPKEY:
2546 case mfDROPLKEY:
2547 case mfDROPCOMPASS:
2548 case mfDROPMAP:
2549 case mfDROPBOSSKEY:
2550 case mfSPAWNNPC:
2551 case mfSWITCHHOOK:
2552 case mfSIDEVIEWLADDER:
2553 case mfSIDEVIEWPLATFORM:
2554 case mfNOENEMYSPAWN:
2555 case mfENEMYALL:
2556 case mfNOMIRROR:
2557 case mfUNSAFEGROUND:
2558 case mf168:
2559 case mf169:
2560 case mf170:
2561 case mf171:
2562 case mf172:
2563 case mf173:
2564 case mf174:
2565 case mf175:
2566 case mf176:
2567 case mf177:
2568 case mf178:
2569 case mf179:
2570 case mf180:
2571 case mf181:
2572 case mf182:
2573 case mf183:
2574 case mf184:
2575 case mf185:
2576 case mf186:
2577 case mf187:
2578 case mf188:
2579 case mf189:
2580 case mf190:
2581 case mf191:
2582 case mf192:
2583 case mf193:
2584 case mf194:
2585 case mf195:
2586 case mf196:
2587 case mf197:
2588 case mf198:
2589 case mf199:
2590 case mf200:
2591 case mf201:
2592 case mf202:
2593 case mf203:
2594 case mf204:
2595 case mf205:
2596 case mf206:
2597 case mf207:
2598 case mf208:
2599 case mf209:
2600 case mf210:
2601 case mf211:
2602 case mf212:
2603 case mf213:
2604 case mf214:
2605 case mf215:
2606 case mf216:
2607 case mf217:
2608 case mf218:
2609 case mf219:
2610 case mf220:
2611 case mf221:
2612 case mf222:
2613 case mf223:
2614 case mf224:
2615 case mf225:
2616 case mf226:
2617 case mf227:
2618 case mf228:
2619 case mf229:
2620 case mf230:
2621 case mf231:
2622 case mf232:
2623 case mf233:
2624 case mf234:
2625 case mf235:
2626 case mf236:
2627 case mf237:
2628 case mf238:
2629 case mf239:
2630 case mf240:
2631 case mf241:
2632 case mf242:
2633 case mf243:
2634 case mf244:
2635 case mf245:
2636 case mf246:
2637 case mf247:
2638 case mf248:
2639 case mf249:
2640 case mf250:
2641 case mf251:
2642 case mf252:
2643 case mf253:
2644 case mf254:
2645 case mfEXTENDED:
2646 2997346 break;
2647
2648 case mfPUSHUD:
2649 case mfPUSHLR:
2650 case mfPUSH4:
2651 case mfPUSHU:
2652 case mfPUSHD:
2653 case mfPUSHL:
2654 case mfPUSHR:
2655 case mfPUSHUDNS:
2656 case mfPUSHLRNS:
2657 case mfPUSH4NS:
2658 case mfPUSHUNS:
2659 case mfPUSHDNS:
2660 case mfPUSHLNS:
2661 case mfPUSHRNS:
2662 case mfPUSHUDINS:
2663 case mfPUSHLRINS:
2664 case mfPUSH4INS:
2665 case mfPUSHUINS:
2666 case mfPUSHDINS:
2667 case mfPUSHLINS:
2668 case mfPUSHRINS:
2669
3/4
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
2638 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2670
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2671 {
2672 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2673 }
2674
2675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2638 times.
2638 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2676
3/6
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 1488 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1488 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2638 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2677 {
2678
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 575 times.
1150 if(hints)
2679 {
2680
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 485 times.
575 switch(combobuf[tmpscr->data[i]].type)
2681 {
2682 case cPUSH_HEAVY:
2683 case cPUSH_HW:
2684 48 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2685 48 tempitemx=x, tempitemy=y;
2686
2687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(tempitem>-1)
2688 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2689
2690 48 break;
2691
2692 case cPUSH_HEAVY2:
2693 case cPUSH_HW2:
2694 42 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2695 42 tempitemx=x, tempitemy=y;
2696
2697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(tempitem>-1)
2698 42 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2699
2700 42 break;
2701 }
2702 575 }
2703 1150 }
2704
2705 2638 break;
2706
2707 case mfWHISTLE:
2708 if(hints)
2709 {
2710 tempitem=getItemID(itemsbuf,itype_whistle,1);
2711
2712 if(tempitem<0) break;
2713
2714 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2715 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2716 {
2717 tempitemx=x;
2718 tempitemy=y;
2719 }
2720
2721 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2722 }
2723
2724 break;
2725
2726 //Why is this here?
2727 case mfFAIRY:
2728 case mfMAGICFAIRY:
2729 case mfALLFAIRY:
2730 if(hints)
2731 {
2732 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2733
2734 if(tempitem < 0) break;
2735
2736 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2737 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2738 {
2739 tempitemx=x;
2740 tempitemy=y;
2741 }
2742
2743 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2744 }
2745
2746 break;
2747
2748 case mfBCANDLE:
2749
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2750 {
2751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2752 252 }
2753 else
2754 {
2755 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2756
2757
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2758
2759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2760
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2761 {
2762 126 tempitemx=x;
2763 126 tempitemy=y;
2764 126 }
2765
2766 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2767 }
2768
2769 504 break;
2770
2771 case mfRCANDLE:
2772 if(!hints)
2773 {
2774 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2775 }
2776 else
2777 {
2778 tempitem=getItemID(itemsbuf,itype_candle,2);
2779
2780 if(tempitem<0) break;
2781
2782 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2783 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2784 {
2785 tempitemx=x;
2786 tempitemy=y;
2787 }
2788
2789 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2790 }
2791
2792 break;
2793
2794 case mfWANDFIRE:
2795 if(!hints)
2796 {
2797 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2798 }
2799 else
2800 {
2801 tempitem=getItemID(itemsbuf,itype_wand,1);
2802
2803 if(tempitem<0) break;
2804
2805 tempweapon=wFire;
2806
2807 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2808 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2809 {
2810 tempitemx=x;
2811 tempitemy=y;
2812 }
2813 else
2814 {
2815 tempweaponx=x;
2816 tempweapony=y;
2817 }
2818
2819 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2820 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2821 }
2822
2823 break;
2824
2825 case mfDINSFIRE:
2826 if(!hints)
2827 {
2828 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2829 }
2830 else
2831 {
2832 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2833
2834 if(tempitem<0) break;
2835
2836 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2837 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2838 {
2839 tempitemx=x;
2840 tempitemy=y;
2841 }
2842
2843 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2844 }
2845
2846 break;
2847
2848 case mfARROW:
2849
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 36 times.
118 if(!hints)
2850 {
2851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2852 36 }
2853 else
2854 {
2855 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2856
2857
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2858
2859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2860
3/6
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2861 {
2862 42 tempitemx=x;
2863 42 tempitemy=y;
2864 42 }
2865
2866 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2867 }
2868
2869 118 break;
2870
2871 case mfSARROW:
2872 if(!hints)
2873 {
2874 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2875 }
2876 else
2877 {
2878 tempitem=getItemID(itemsbuf,itype_arrow,2);
2879
2880 if(tempitem<0) break;
2881
2882 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2883 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2884 {
2885 tempitemx=x;
2886 tempitemy=y;
2887 }
2888
2889 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2890 }
2891
2892 break;
2893
2894 case mfGARROW:
2895 if(!hints)
2896 {
2897 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2898 }
2899 else
2900 {
2901 tempitem=getItemID(itemsbuf,itype_arrow,3);
2902
2903 if(tempitem<0) break;
2904
2905 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2906 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2907 {
2908 tempitemx=x;
2909 tempitemy=y;
2910 }
2911
2912 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2913 }
2914
2915 break;
2916
2917 case mfBOMB:
2918
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
2919 {
2920 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2921 }
2922 else
2923 {
2924 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2925 17 tempweapon = wLitBomb;
2926
2927 //if (tempitem<0) break;
2928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2929
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2930 {
2931 8 tempweaponx=x;
2932 8 tempweapony=y;
2933 8 }
2934
2935 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2936 }
2937
2938 17 break;
2939
2940 case mfSBOMB:
2941
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2942 {
2943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2944 48 }
2945 else
2946 {
2947 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2948 //if (tempitem<0) break;
2949 48 tempweapon = wLitSBomb;
2950
2951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2952
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2953 {
2954 24 tempweaponx=x;
2955 24 tempweapony=y;
2956 24 }
2957
2958 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2959 }
2960
2961 96 break;
2962
2963 case mfARMOS_SECRET:
2964
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
2965 {
2966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2967 12 }
2968 24 break;
2969
2970 case mfBRANG:
2971
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
2972 {
2973 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2974 }
2975 else
2976 {
2977 5 tempitem=getItemID(itemsbuf,itype_brang,1);
2978
2979
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
2980
2981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2982
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2983 {
2984 3 tempitemx=x;
2985 3 tempitemy=y;
2986 3 }
2987
2988 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2989 }
2990
2991 5 break;
2992
2993 case mfMBRANG:
2994 if(!hints)
2995 {
2996 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
2997 }
2998 else
2999 {
3000 tempitem=getItemID(itemsbuf,itype_brang,2);
3001
3002 if(tempitem<0) break;
3003
3004 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3005 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3006 {
3007 tempitemx=x;
3008 tempitemy=y;
3009 }
3010
3011 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3012 }
3013
3014 break;
3015
3016 case mfFBRANG:
3017 if(!hints)
3018 {
3019 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3020 }
3021 else
3022 {
3023 tempitem=getItemID(itemsbuf,itype_brang,3);
3024
3025 if(tempitem<0) break;
3026
3027 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3028 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3029 {
3030 tempitemx=x;
3031 tempitemy=y;
3032 }
3033
3034 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3035 }
3036
3037 break;
3038
3039 case mfWANDMAGIC:
3040 if(!hints)
3041 {
3042 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3043 }
3044 else
3045 {
3046 tempitem=getItemID(itemsbuf,itype_wand,1);
3047
3048 if(tempitem<0) break;
3049
3050 tempweapon=itemsbuf[tempitem].wpn3;
3051
3052 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3053 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3054 {
3055 tempitemx=x;
3056 tempitemy=y;
3057 }
3058 else
3059 {
3060 tempweaponx=x;
3061 tempweapony=y;
3062 --lens_hint_weapon[wMagic][4];
3063
3064 if(lens_hint_weapon[wMagic][4]<-8)
3065 {
3066 lens_hint_weapon[wMagic][4]=8;
3067 }
3068 }
3069
3070 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3071 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3072 }
3073
3074 break;
3075
3076 case mfREFMAGIC:
3077
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3078 {
3079 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3080 }
3081 else
3082 {
3083 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3084
3085
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3086
3087 16 tempweapon=ewMagic;
3088
3089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3090
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3091 {
3092 8 tempitemx=x;
3093 8 tempitemy=y;
3094 8 }
3095 else
3096 {
3097 8 tempweaponx=x;
3098 8 tempweapony=y;
3099
3100
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(lens_hint_weapon[ewMagic][2]==up)
3101 {
3102 1 --lens_hint_weapon[ewMagic][4];
3103 1 }
3104 else
3105 {
3106 7 ++lens_hint_weapon[ewMagic][4];
3107 }
3108
3109
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewMagic][4]>8)
3110 {
3111 lens_hint_weapon[ewMagic][2]=up;
3112 }
3113
3114
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(lens_hint_weapon[ewMagic][4]<=0)
3115 {
3116 2 lens_hint_weapon[ewMagic][2]=down;
3117 2 }
3118 }
3119
3120 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3121 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3122 }
3123
3124 16 break;
3125
3126 case mfREFFIREBALL:
3127
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3128 {
3129 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3130 }
3131 else
3132 {
3133 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3134
3135
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3136
3137 16 tempweapon=ewFireball;
3138
3139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3140
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3141 {
3142 8 tempitemx=x;
3143 8 tempitemy=y;
3144 8 tempweaponx=x;
3145 8 tempweapony=y;
3146 8 ++lens_hint_weapon[ewFireball][3];
3147
3148
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>8)
3149 {
3150 lens_hint_weapon[ewFireball][3]=-8;
3151 lens_hint_weapon[ewFireball][4]=8;
3152 }
3153
3154
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>0)
3155 {
3156 8 ++lens_hint_weapon[ewFireball][4];
3157 8 }
3158 else
3159 {
3160 --lens_hint_weapon[ewFireball][4];
3161 }
3162 8 }
3163
3164 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3165 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3166 }
3167
3168 16 break;
3169
3170 case mfSWORD:
3171
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3172 {
3173 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3174 }
3175 else
3176 {
3177 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3178
3179
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3180
3181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3182
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3183 {
3184 3 tempitemx=x;
3185 3 tempitemy=y;
3186 3 }
3187
3188 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3189 }
3190
3191 7 break;
3192
3193 case mfWSWORD:
3194 if(!hints)
3195 {
3196 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3197 }
3198 else
3199 {
3200 tempitem=getItemID(itemsbuf,itype_sword,2);
3201
3202 if(tempitem<0) break;
3203
3204 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3205 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3206 {
3207 tempitemx=x;
3208 tempitemy=y;
3209 }
3210
3211 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3212 }
3213
3214 break;
3215
3216 case mfMSWORD:
3217 if(!hints)
3218 {
3219 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3220 }
3221 else
3222 {
3223 tempitem=getItemID(itemsbuf,itype_sword,3);
3224
3225 if(tempitem<0) break;
3226
3227 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3228 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3229 {
3230 tempitemx=x;
3231 tempitemy=y;
3232 }
3233
3234 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3235 }
3236
3237 break;
3238
3239 case mfXSWORD:
3240 if(!hints)
3241 {
3242 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3243 }
3244 else
3245 {
3246 tempitem=getItemID(itemsbuf,itype_sword,4);
3247
3248 if(tempitem<0) break;
3249
3250 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3251 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3252 {
3253 tempitemx=x;
3254 tempitemy=y;
3255 }
3256
3257 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3258 }
3259
3260 break;
3261
3262 case mfSWORDBEAM:
3263
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3264 {
3265 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3266 }
3267 else
3268 {
3269 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3270
3271
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3272
3273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3274
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3275 {
3276 8 tempitemx=x;
3277 8 tempitemy=y;
3278 8 }
3279
3280 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3281 }
3282
3283 16 break;
3284
3285 case mfWSWORDBEAM:
3286 if(!hints)
3287 {
3288 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3289 }
3290 else
3291 {
3292 tempitem=getItemID(itemsbuf,itype_sword,2);
3293
3294 if(tempitem<0) break;
3295
3296 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3297 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3298 {
3299 tempitemx=x;
3300 tempitemy=y;
3301 }
3302
3303 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3304 }
3305
3306 break;
3307
3308 case mfMSWORDBEAM:
3309 if(!hints)
3310 {
3311 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3312 }
3313 else
3314 {
3315 tempitem=getItemID(itemsbuf,itype_sword,3);
3316
3317 if(tempitem<0) break;
3318
3319 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3320 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3321 {
3322 tempitemx=x;
3323 tempitemy=y;
3324 }
3325
3326 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3327 }
3328
3329 break;
3330
3331 case mfXSWORDBEAM:
3332 if(!hints)
3333 {
3334 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3335 }
3336 else
3337 {
3338 tempitem=getItemID(itemsbuf,itype_sword,4);
3339
3340 if(tempitem<0) break;
3341
3342 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3343 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3344 {
3345 tempitemx=x;
3346 tempitemy=y;
3347 }
3348
3349 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3350 }
3351
3352 break;
3353
3354 case mfHOOKSHOT:
3355
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3356 {
3357 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3358 }
3359 else
3360 {
3361 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3362
3363
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3364
3365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3366
3/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3367 {
3368 9 tempitemx=x;
3369 9 tempitemy=y;
3370 9 }
3371
3372 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3373 }
3374
3375 17 break;
3376
3377 case mfWAND:
3378
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3379 {
3380 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3381 }
3382 else
3383 {
3384 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3385
3386
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3387
3388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3389
3/6
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3390 {
3391 17 tempitemx=x;
3392 17 tempitemy=y;
3393 17 }
3394
3395 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3396 }
3397
3398 35 break;
3399
3400 case mfHAMMER:
3401
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3402 {
3403 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3404 }
3405 else
3406 {
3407 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3408
3409
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3410
3411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3412
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3413 {
3414 8 tempitemx=x;
3415 8 tempitemy=y;
3416 8 }
3417
3418 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3419 }
3420
3421 17 break;
3422
3423 case mfARMOS_ITEM:
3424 case mfDIVE_ITEM:
3425
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3426 {
3427 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3428 2064 }
3429 2064 break;
3430
3431 case 16:
3432 case 17:
3433 case 18:
3434 case 19:
3435 case 20:
3436 case 21:
3437 case 22:
3438 case 23:
3439 case 24:
3440 case 25:
3441 case 26:
3442 case 27:
3443 case 28:
3444 case 29:
3445 case 30:
3446 case 31:
3447
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 1008 times.
2016 if(!hints)
3448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1008 times.
2016 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3449 1008 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3450
3451 2016 break;
3452 case mfSECRETSNEXT:
3453 if(!hints)
3454 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3455 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3456
3457 break;
3458
3459 case mfSTRIKE:
3460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3461 {
3462 192 goto special;
3463 }
3464 else
3465 {
3466 break;
3467 }
3468
3469 28392 default: goto special;
3470
3471 special:
3472
8/8
✓ Branch 0 taken 14196 times.
✓ Branch 1 taken 14388 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 14088 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8004 times.
28584 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3473 {
3474
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
✓ Branch 2 taken 3096 times.
✓ Branch 3 taken 3096 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3096 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6192 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3475 {
3476 3096 rectfill(dest,x,y,x+15,y+15,WHITE);
3477 3096 }
3478 6192 }
3479
3480 28584 break;
3481 }
3482 3033536 }
3483 1516768 }
3484
3485
2/2
✓ Branch 0 taken 4309 times.
✓ Branch 1 taken 4309 times.
8618 if(layer)
3486 {
3487
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 108 times.
4309 if(tmpscr->door[0]==dWALK)
3488 108 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3489
3490
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 108 times.
4309 if(tmpscr->door[1]==dWALK)
3491 108 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3492
3493
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[2]==dWALK)
3494 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3495
3496
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[3]==dWALK)
3497 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3498
3499
2/2
✓ Branch 0 taken 4285 times.
✓ Branch 1 taken 24 times.
4309 if(tmpscr->door[0]==dBOMB)
3500 {
3501 24 showbombeddoor(dest, 0);
3502 24 }
3503
3504
2/2
✓ Branch 0 taken 4285 times.
✓ Branch 1 taken 24 times.
4309 if(tmpscr->door[1]==dBOMB)
3505 {
3506 24 showbombeddoor(dest, 1);
3507 24 }
3508
3509
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[2]==dBOMB)
3510 {
3511 showbombeddoor(dest, 2);
3512 }
3513
3514
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[3]==dBOMB)
3515 {
3516 showbombeddoor(dest, 3);
3517 }
3518 4309 }
3519
3520
2/2
✓ Branch 0 taken 6796 times.
✓ Branch 1 taken 1822 times.
8618 if(tmpscr->stairx + tmpscr->stairy)
3521 {
3522
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 911 times.
1822 if(!hints)
3523 {
3524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 911 times.
911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3525 911 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3526 911 }
3527 else
3528 {
3529
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3530 {
3531 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3532 48 int32_t tempitemx=-16;
3533 48 int32_t tempitemy=-16;
3534
3535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3536
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3537 {
3538 tempitemx=tmpscr->stairx;
3539 tempitemy=tmpscr->stairy+playing_field_offset;
3540 }
3541
3542 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3543 48 }
3544 }
3545 1822 }
3546 }
3547 8618 }
3548
3549 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3550
3551 4140 void draw_lens_over()
3552 {
3553 // Oh, what the heck.
3554 static BITMAP *lens_scr = NULL;
3555 static int32_t last_width = -1;
3556 4140 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3557
3558 // Only redraw the circle if the size has changed
3559
2/2
✓ Branch 0 taken 4138 times.
✓ Branch 1 taken 2 times.
4140 if(width != last_width)
3560 {
3561
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(lens_scr == NULL)
3562 {
3563 2 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3564 2 }
3565
3566 2 clear_to_color(lens_scr, BLACK);
3567 2 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3568 2 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3569 2 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3570 2 last_width=width;
3571 2 }
3572
3573 4140 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3574 4140 }
3575
3576 //----------------------------------------------------------------
3577
3578 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3579 {
3580 //recreating a big bitmap every frame is highly sluggish.
3581
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3582 30701 clear_to_color(wavebuf, BLACK);
3583 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3584
3585 int32_t ofs;
3586 // int32_t amplitude=8;
3587 // int32_t wavelength=4;
3588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3589
2/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30701 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30701 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3590 30701 int32_t amp2=168;
3591
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30701 times.
✗ Branch 3 not taken.
30701 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3592 30701 int32_t i=frame%amp2;
3593
3594
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3595 {
3596
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3597 {
3598 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3599 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3600 }
3601 else
3602 {
3603 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3604 }
3605
3606
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3607 {
3608
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3609 {
3610 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3611 1320388608 }
3612 5157768 }
3613 5157768 }
3614 30701 }
3615
3616 576 void draw_fuzzy(int32_t fuzz)
3617 // draws from right half of scrollbuf to framebuf
3618 {
3619 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3620 byte *start, *si, *di;
3621
3622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(fuzz<1)
3623 fuzz = 1;
3624
3625 576 xstep = 128%fuzz;
3626
3627
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 456 times.
576 if(xstep > 0)
3628 456 xstep = fuzz-xstep;
3629
3630 576 ystep = 112%fuzz;
3631
3632
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 408 times.
576 if(ystep > 0)
3633 408 ystep = fuzz-ystep;
3634
3635 576 firsty = 1;
3636
3637
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 20784 times.
21360 for(y=0; y<224;)
3638 {
3639 20784 start = &(scrollbuf->line[y][256]);
3640
3641
4/4
✓ Branch 0 taken 20496 times.
✓ Branch 1 taken 129312 times.
✓ Branch 2 taken 129024 times.
✓ Branch 3 taken 20784 times.
149808 for(dy=0; dy<ystep && dy+y<224; dy++)
3642 {
3643 129024 si = start;
3644 129024 di = &(framebuf->line[y+dy][0]);
3645 129024 i = xstep;
3646 129024 firstx = 1;
3647
3648
2/2
✓ Branch 0 taken 33030144 times.
✓ Branch 1 taken 129024 times.
33159168 for(dx=0; dx<256; dx++)
3649 {
3650 33030144 *(di++) = *si;
3651
3652
2/2
✓ Branch 0 taken 27831552 times.
✓ Branch 1 taken 5198592 times.
33030144 if(++i >= fuzz)
3653 {
3654
2/2
✓ Branch 0 taken 5069568 times.
✓ Branch 1 taken 129024 times.
5198592 if(!firstx)
3655 5069568 si += fuzz;
3656 else
3657 {
3658 129024 si += fuzz-xstep;
3659 129024 firstx = 0;
3660 }
3661
3662 5198592 i = 0;
3663 5198592 }
3664 33030144 }
3665 129024 }
3666
3667
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 576 times.
20784 if(!firsty)
3668 20208 y += fuzz;
3669 else
3670 {
3671 576 y += ystep;
3672 576 ystep = fuzz;
3673 576 firsty = 0;
3674 }
3675 }
3676 576 }
3677
3678 4329767 void updatescr(bool allowwavy)
3679 {
3680
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 4329743 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
4329767 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3681
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 4329743 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
4329767 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3682
3683
2/2
✓ Branch 0 taken 4304063 times.
✓ Branch 1 taken 25704 times.
4329767 if(toogam)
3684 {
3685 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3686 25704 }
3687
3688
1/2
✓ Branch 0 taken 4329767 times.
✗ Branch 1 not taken.
4329767 if(Showpal)
3689 dump_pal(framebuf);
3690
3691
2/2
✓ Branch 0 taken 4270252 times.
✓ Branch 1 taken 59515 times.
4329767 if(!Playing)
3692 59515 black_opening_count=0;
3693
3694
2/2
✓ Branch 0 taken 4308647 times.
✓ Branch 1 taken 21120 times.
4329767 if(black_opening_count<0) //shape is opening up
3695 {
3696 21120 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3697
3698
2/4
✓ Branch 0 taken 21120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21120 times.
21120 if(Advance||(!Paused))
3699 {
3700 21120 ++black_opening_count;
3701 21120 }
3702 21120 }
3703
2/2
✓ Branch 0 taken 4299407 times.
✓ Branch 1 taken 9240 times.
4308647 else if(black_opening_count>0) //shape is closing
3704 {
3705 9240 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3706
3707
2/4
✓ Branch 0 taken 9240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9240 times.
9240 if(Advance||(!Paused))
3708 {
3709 9240 --black_opening_count;
3710 9240 }
3711 9240 }
3712
3713
3/4
✓ Branch 0 taken 4299867 times.
✓ Branch 1 taken 29900 times.
✓ Branch 2 taken 4299867 times.
✗ Branch 3 not taken.
4329767 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3714 {
3715 black_opening_shape = bosCIRCLE;
3716 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3717 refreshTints();
3718 refreshpal=true;
3719 }
3720
3721
2/2
✓ Branch 0 taken 4226182 times.
✓ Branch 1 taken 103585 times.
4329767 if(refreshpal)
3722 {
3723 103585 refreshpal=false;
3724 103585 RAMpal[253] = _RGB(0,0,0);
3725 103585 RAMpal[254] = _RGB(63,63,63);
3726 103585 hw_palette = &RAMpal;
3727 103585 update_hw_pal = true;
3728
3729 103585 create_rgb_table(&rgb_table, RAMpal, NULL);
3730 103585 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3731 103585 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3732
3733
2/2
✓ Branch 0 taken 26517760 times.
✓ Branch 1 taken 103585 times.
26621345 for(int32_t q=0; q<PAL_SIZE; q++)
3734 {
3735 26517760 trans_table2.data[0][q] = q;
3736 26517760 trans_table2.data[q][q] = q;
3737 26517760 }
3738 103585 }
3739
3740 4329767 bool clearwavy = (wavy <= 0);
3741
3742
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 4322522 times.
4329767 if(wavy <= 0)
3743 {
3744 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3745 4322522 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3746 4322522 }
3747
3748 4329767 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3749
3750
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 4298816 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
4329767 if(wavy && Playing && allowwavy)
3751 {
3752 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3753 30701 }
3754
3755
2/2
✓ Branch 0 taken 4322522 times.
✓ Branch 1 taken 7245 times.
4329767 if(clearwavy)
3756 4322522 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3757
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3758 7245 wavy--; // Wavy was set by a script. Decrement it.
3759
3760
5/6
✓ Branch 0 taken 4270252 times.
✓ Branch 1 taken 59515 times.
✓ Branch 2 taken 78694 times.
✓ Branch 3 taken 4191558 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 78694 times.
4329767 if(Playing && msgpos && !screenscrolling)
3761 {
3762
1/2
✓ Branch 0 taken 78694 times.
✗ Branch 1 not taken.
78694 if(!(msg_bg_display_buf->clip))
3763 78694 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3764
1/2
✓ Branch 0 taken 78694 times.
✗ Branch 1 not taken.
78694 if(!(msg_portrait_display_buf->clip))
3765 78694 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3766
1/2
✓ Branch 0 taken 78694 times.
✗ Branch 1 not taken.
78694 if(!(msg_txt_display_buf->clip))
3767 78694 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3768 78694 }
3769
3770 /*
3771 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3772 {
3773 BITMAP* subBmp = 0;
3774 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3775 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3776 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3777 destroy_bitmap(subBmp);
3778 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3779 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3780 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3781 }
3782 */
3783
3784
2/2
✓ Branch 0 taken 4314638 times.
✓ Branch 1 taken 15129 times.
4329767 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3785
3786
2/2
✓ Branch 0 taken 4314638 times.
✓ Branch 1 taken 15129 times.
4329767 if(nosubscr)
3787 {
3788 15129 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3789 15129 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3790 15129 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3791 15129 }
3792
3793 //TODO: Optimize blit 'overcalls' -Gleeok
3794
2/2
✓ Branch 0 taken 15129 times.
✓ Branch 1 taken 4314638 times.
4329767 BITMAP *source = nosubscr ? panorama : wavybuf;
3795 4329767 blit(source,framebuf,0,0,0,0,256,224);
3796
3797 4329767 update_hw_screen();
3798 4329767 }
3799
3800 //----------------------------------------------------------------
3801
3802 PALETTE sys_pal;
3803
3804 int32_t onGUISnapshot()
3805 {
3806 char buf[200];
3807 int32_t num=0;
3808 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3809 do
3810 {
3811 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3812 }
3813 while(num<99999 && exists(buf));
3814
3815 BITMAP *b = create_bitmap_ex(8,resx,resy);
3816
3817 if(b)
3818 {
3819 if(MenuOpen)
3820 {
3821 //Cannot load game's palette while GUI elements are in focus. -Z
3822 //If there is a way to do this, then I have missed it.
3823 /*
3824 game_pal();
3825 RAMpal[253] = _RGB(0,0,0);
3826 RAMpal[254] = _RGB(63,63,63);
3827 set_palette_range(RAMpal,0,255,false);
3828 memcpy(RAMpal, snappal, sizeof(snappal));
3829 create_rgb_table(&rgb_table, RAMpal, NULL);
3830 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3831 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3832
3833 for(int32_t q=0; q<PAL_SIZE; q++)
3834 {
3835 trans_table2.data[0][q] = q;
3836 trans_table2.data[q][q] = q;
3837 }
3838 */
3839 //ringcolor(false);
3840 //get_palette(RAMpal);
3841 blit(screen,b,0,0,0,0,resx,resy);
3842 //al_trace("Menu Open\n");
3843 //game_pal();
3844 //PALETTE temppal;
3845 //get_palette(temppal);
3846 //system_pal();
3847 save_bitmap(buf,b,sys_pal);
3848 //save_bitmap(buf,b,RAMpal);
3849 //save_bitmap(buf,b,snappal);
3850 }
3851 else
3852 {
3853 blit(screen,b,0,0,0,0,resx,resy);
3854 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3855 }
3856 destroy_bitmap(b);
3857 }
3858
3859 return D_O_K;
3860 }
3861
3862 int32_t onNonGUISnapshot()
3863 {
3864 PALETTE temppal;
3865 get_palette(temppal);
3866 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3867
3868 char buf[200];
3869 int32_t num=0;
3870
3871 do
3872 {
3873 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3874 }
3875 while(num<99999 && exists(buf));
3876
3877 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3878
3879 return D_O_K;
3880 }
3881
3882 int32_t onSnapshot()
3883 {
3884 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3885 {
3886 onGUISnapshot();
3887 }
3888 else
3889 {
3890 onNonGUISnapshot();
3891 }
3892
3893 return D_O_K;
3894 }
3895
3896 int32_t onSaveMapPic()
3897 {
3898 int32_t mapres2 = 0;
3899 char buf[200];
3900 int32_t num=0;
3901 mapscr tmpscr_b[2];
3902 mapscr tmpscr_c[6];
3903 BITMAP* _screen_draw_buffer = NULL;
3904 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3905 set_clip_state(_screen_draw_buffer,1);
3906
3907 for(int32_t i=0; i<6; ++i)
3908 {
3909 tmpscr_c[i] = tmpscr2[i];
3910 tmpscr2[i].zero_memory();
3911
3912 if(i>=2)
3913 {
3914 continue;
3915 }
3916
3917 tmpscr_b[i] = tmpscr[i];
3918 tmpscr[i].zero_memory();
3919 }
3920
3921 do
3922 {
3923 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3924 }
3925 while(num<99999 && exists(buf));
3926
3927 BITMAP* mappic = NULL;
3928
3929
3930 bool done=false, redraw=true;
3931
3932 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3933
3934 if(!mappic)
3935 {
3936 system_pal();
3937 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3938 game_pal();
3939 return D_O_K;;
3940 }
3941
3942 // draw the map
3943 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3944
3945 for(int32_t y=0; y<8; y++)
3946 {
3947 for(int32_t x=0; x<16; x++)
3948 {
3949 if(!displayOnMap(x, y))
3950 {
3951 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3952 }
3953 else
3954 {
3955 int32_t s = (y<<4) + x;
3956 loadscr2(1,s,-1);
3957
3958 for(int32_t i=0; i<6; i++)
3959 {
3960 if(tmpscr[1].layermap[i]<=0)
3961 continue;
3962
3963 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
3964 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
3965 {
3966 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
3967
3968 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
3969 }
3970 }
3971
3972 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3973
3974 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3975
3976 putscr(_screen_draw_buffer,256,0,tmpscr+1);
3977 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
3978
3979 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3980
3981 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
3982 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
3983 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
3984 {
3985 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
3986 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
3987 }
3988 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
3989
3990 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3991
3992 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
3993 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
3994 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
3995 {
3996 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
3997 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
3998 }
3999 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4000 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4001
4002 }
4003
4004 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4005 }
4006 }
4007
4008 for(int32_t i=0; i<6; ++i)
4009 {
4010 tmpscr2[i]=tmpscr_c[i];
4011
4012 if(i>=2)
4013 {
4014 continue;
4015 }
4016
4017 tmpscr[i]=tmpscr_b[i];
4018 }
4019
4020 save_bitmap(buf,mappic,RAMpal);
4021 destroy_bitmap(mappic);
4022 destroy_bitmap(_screen_draw_buffer);
4023 return D_O_K;
4024 }
4025
4026 /*
4027 int32_t onSaveMapPic()
4028 {
4029 BITMAP* mappic = NULL;
4030 BITMAP* _screen_draw_buffer = NULL;
4031 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4032 int32_t mapres2 = 0;
4033 char buf[20];
4034 int32_t num=0;
4035 set_clip_state(_screen_draw_buffer,1);
4036 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4037
4038 do
4039 {
4040 sprintf(buf, "zelda%03d.png", ++num);
4041 }
4042 while(num<999 && exists(buf));
4043
4044 // if(!mappic) {
4045 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4046
4047 if(!mappic)
4048 {
4049 system_pal();
4050 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4051 game_pal();
4052 return D_O_K;
4053 }
4054
4055 // }
4056
4057 int32_t layermap, layerscreen;
4058 int32_t x2=0;
4059
4060 // draw the map
4061 for(int32_t y=0; y<8; y++)
4062 {
4063 for(int32_t x=0; x<16; x++)
4064 {
4065 int32_t s = (y<<4) + x;
4066
4067 if(!displayOnMap(x, y))
4068 {
4069 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4070 }
4071 else
4072 {
4073 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4074 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4075
4076 for(int32_t k=0; k<4; k++)
4077 {
4078 if(k==2)
4079 {
4080 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4081 }
4082
4083 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4084
4085 if(layermap>-1)
4086 {
4087 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4088
4089 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4090 {
4091 for(int32_t i=0; i<176; i++)
4092 {
4093 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4094 }
4095 }
4096 else
4097 {
4098 for(int32_t i=0; i<176; i++)
4099 {
4100 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4101 }
4102 }
4103 }
4104 }
4105
4106 for(int32_t i=0; i<176; i++)
4107 {
4108 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4109 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4110 {
4111 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4112 }
4113 }
4114
4115 for(int32_t k=4; k<6; k++)
4116 {
4117 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4118
4119 if(layermap>-1)
4120 {
4121 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4122
4123 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4124 {
4125 for(int32_t i=0; i<176; i++)
4126 {
4127 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4128 }
4129 }
4130 else
4131 {
4132 for(int32_t i=0; i<176; i++)
4133 {
4134 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4135 }
4136 }
4137 }
4138 }
4139 }
4140
4141 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4142 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4143 }
4144
4145 }
4146
4147 save_bitmap(buf,mappic,RAMpal);
4148 destroy_bitmap(mappic);
4149 destroy_bitmap(_screen_draw_buffer);
4150 return D_O_K;
4151 }
4152 */
4153
4154 14 void f_Quit(int32_t type)
4155 {
4156
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4157 return;
4158
4159 14 bool from_menu = is_sys_pal;
4160
4161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4162 {
4163 14 music_pause();
4164 14 pause_all_sfx();
4165 14 }
4166 14 enter_sys_pal();
4167 14 clear_keybuf();
4168
4169 14 replay_poll();
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4171 14 replay_peek_quit();
4172
4173
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4174 switch(type)
4175 {
4176 case qQUIT:
4177 onQuit();
4178 break;
4179
4180 case qRESET:
4181 onReset();
4182 break;
4183
4184 case qEXIT:
4185 onExit();
4186 break;
4187 }
4188
4189
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4190 {
4191 14 kill_sfx();
4192 14 music_stop();
4193 14 exit_sys_pal();
4194 14 update_hw_screen();
4195 14 }
4196 else
4197 {
4198 exit_sys_pal();
4199 if(!from_menu)
4200 {
4201 music_resume();
4202 resume_all_sfx();
4203 }
4204 }
4205
4206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4207 14 show_mouse(NULL);
4208 14 eat_buttons();
4209
4210 14 zc_readrawkey(KEY_ESC);
4211
4212 14 zc_readrawkey(KEY_ENTER);
4213 14 }
4214
4215 //----------------------------------------------------------------
4216
4217 int32_t onNoWalls()
4218 {
4219 cheats_enqueue(Cheat::Walls);
4220 return D_O_K;
4221 }
4222
4223 int32_t onIgnoreSideview()
4224 {
4225 cheats_enqueue(Cheat::IgnoreSideView);
4226 return D_O_K;
4227 }
4228
4229 4391436 int32_t input_idle(bool checkmouse)
4230 {
4231 static int32_t mx, my, mz, mb;
4232
4233
4/6
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 991354 times.
✓ Branch 3 taken 3400082 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 991354 times.
5382790 if(keypressed() || zc_key_pressed() ||
4234
4/8
✓ Branch 0 taken 991354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 991354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 991354 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 991354 times.
✗ Branch 7 not taken.
991354 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4235 {
4236 3400082 idle_count = 0;
4237
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3400082 times.
3400082 if(active_count < MAX_ACTIVE)
4239 {
4240 3400082 ++active_count;
4241 3400082 }
4242 3400082 }
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 991354 times.
991354 else if(idle_count < MAX_IDLE)
4244 {
4245 991354 ++idle_count;
4246 991354 active_count = 0;
4247 991354 }
4248
4249 4391436 mx = mouse_x;
4250 4391436 my = mouse_y;
4251 4391436 mz = mouse_z;
4252 4391436 mb = mouse_b;
4253
4254 4391436 return idle_count;
4255 }
4256
4257 int32_t onGoFast()
4258 {
4259 cheats_enqueue(Cheat::Fast);
4260 return D_O_K;
4261 }
4262
4263 int32_t onKillCheat()
4264 {
4265 cheats_enqueue(Cheat::Kill);
4266 return D_O_K;
4267 }
4268
4269 int32_t onShowLayer0()
4270 {
4271 show_layer_0 = !show_layer_0;
4272 return D_O_K;
4273 }
4274 int32_t onShowLayer1()
4275 {
4276 show_layer_1 = !show_layer_1;
4277 return D_O_K;
4278 }
4279 int32_t onShowLayer2()
4280 {
4281 show_layer_2 = !show_layer_2;
4282 return D_O_K;
4283 }
4284 int32_t onShowLayer3()
4285 {
4286 show_layer_3 = !show_layer_3;
4287 return D_O_K;
4288 }
4289 int32_t onShowLayer4()
4290 {
4291 show_layer_4 = !show_layer_4;
4292 return D_O_K;
4293 }
4294 int32_t onShowLayer5()
4295 {
4296 show_layer_5 = !show_layer_5;
4297 return D_O_K;
4298 }
4299 int32_t onShowLayer6()
4300 {
4301 show_layer_6 = !show_layer_6;
4302 return D_O_K;
4303 }
4304 int32_t onShowLayerO()
4305 {
4306 show_layer_over=!show_layer_over;
4307 return D_O_K;
4308 }
4309 int32_t onShowLayerP()
4310 {
4311 show_layer_push=!show_layer_push;
4312 return D_O_K;
4313 }
4314 int32_t onShowLayerS()
4315 {
4316 show_sprites=!show_sprites;
4317 return D_O_K;
4318 }
4319 int32_t onShowLayerF()
4320 {
4321 show_ffcs=!show_ffcs;
4322 return D_O_K;
4323 }
4324 int32_t onShowLayerW()
4325 {
4326 show_walkflags=!show_walkflags;
4327 return D_O_K;
4328 }
4329 int32_t onShowLayerE()
4330 {
4331 show_effectflags=!show_effectflags;
4332 return D_O_K;
4333 }
4334 int32_t onShowFFScripts()
4335 {
4336 show_ff_scripts=!show_ff_scripts;
4337 return D_O_K;
4338 }
4339 int32_t onShowHitboxes()
4340 {
4341 show_hitboxes=!show_hitboxes;
4342 return D_O_K;
4343 }
4344
4345 int32_t onLightSwitch()
4346 {
4347 cheats_enqueue(Cheat::Light);
4348 return D_O_K;
4349 }
4350
4351 int32_t onGoTo();
4352 int32_t onGoToComplete();
4353
4354 4391436 void syskeys()
4355 {
4356 4391436 update_system_keys();
4357
4358 int32_t oldtitle_version;
4359
4360
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(close_button_quit)
4361 {
4362 close_button_quit=false;
4363 f_Quit(qEXIT);
4364 }
4365
4366 4391436 poll_joystick();
4367
4368
2/10
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4391436 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4391436 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4369 {
4370 oldtitle_version=title_version;
4371 System();
4372 }
4373
4374 4391436 mouse_down=gui_mouse_b();
4375
4376
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(zc_read_system_key(KEY_F1))
4377 {
4378 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4379 {
4380 halt=!halt;
4381 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4382 }
4383 else
4384 {
4385 Throttlefps=!Throttlefps;
4386 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4387 logic_counter=0;
4388 }
4389 }
4390
4391 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4392 /*
4393 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4394 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4395 */
4396
4397
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(zc_read_system_key(KEY_F2))
4398 {
4399 ShowFPS=!ShowFPS;
4400 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4401 }
4402
4403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4391436 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4391436 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4404
4405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4391436 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4391436 if(zc_read_system_key(KEY_F4) && Playing)
4406 {
4407 Paused=true;
4408 Advance=true;
4409 }
4410
4411
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(zc_read_system_key(KEY_F6)) onTryQuit();
4412
4413 #ifndef ALLEGRO_MACOSX
4414
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4415
4416
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4417 #else
4418 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4419
4420 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4421 #endif
4422
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4391436 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4391436 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4423
4424
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if (zc_read_system_key(KEY_F12))
4425 {
4426 onSnapshot();
4427 }
4428
4429
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4391436 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4391436 if(debug_enabled && zc_read_system_key(KEY_TAB))
4430 set_debug(!get_debug());
4431
4432
3/4
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21292 times.
✓ Branch 3 taken 4370144 times.
4391436 if(get_debug() || cheat>=1)
4433 {
4434
1/2
✓ Branch 0 taken 21292 times.
✗ Branch 1 not taken.
21292 if( CheatModifierKeys() )
4435 {
4436 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4437
4438 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4439
4440 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4441
4442 if(zc_readkey(KEY_B))
4443 {
4444 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4445 }
4446
4447 if(zc_readkey(KEY_A))
4448 {
4449 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4450 }
4451 }
4452 21292 }
4453
4454
3/4
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21292 times.
✓ Branch 3 taken 4370144 times.
4391436 if(get_debug() || cheat>=2)
4455 {
4456
1/2
✓ Branch 0 taken 21292 times.
✗ Branch 1 not taken.
21292 if( CheatModifierKeys() )
4457 {
4458 if(rI())
4459 {
4460 cheats_enqueue(Cheat::Clock);
4461 }
4462 }
4463 21292 }
4464
4465
3/4
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21292 times.
✓ Branch 3 taken 4370144 times.
4391436 if(get_debug() || cheat>=4)
4466 {
4467
1/2
✓ Branch 0 taken 21292 times.
✗ Branch 1 not taken.
21292 if( CheatModifierKeys() )
4468 {
4469 if(rF11())
4470 {
4471 cheats_enqueue(Cheat::Walls);
4472 }
4473
4474 if(rQ())
4475 {
4476 cheats_enqueue(Cheat::Fast);
4477 }
4478
4479 if(zc_readkey(KEY_F))
4480 {
4481 cheats_enqueue(Cheat::Freeze);
4482 }
4483
4484 if(zc_readkey(KEY_G)) onGoToComplete();
4485
4486 if(zc_readkey(KEY_0)) onShowLayer0();
4487
4488 if(zc_readkey(KEY_1)) onShowLayer1();
4489
4490 if(zc_readkey(KEY_2)) onShowLayer2();
4491
4492 if(zc_readkey(KEY_3)) onShowLayer3();
4493
4494 if(zc_readkey(KEY_4)) onShowLayer4();
4495
4496 if(zc_readkey(KEY_5)) onShowLayer5();
4497
4498 if(zc_readkey(KEY_6)) onShowLayer6();
4499
4500 //if(zc_readkey(KEY_7)) onShowLayerO();
4501 if(zc_readkey(KEY_7)) onShowLayerF();
4502
4503 if(zc_readkey(KEY_8)) onShowLayerS();
4504
4505 if(zc_readkey(KEY_W)) onShowLayerW();
4506
4507 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4508
4509 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4510
4511 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4512 if(zc_readkey(KEY_O)) onShowLayerO();
4513 if(zc_readkey(KEY_P)) onShowLayerP();
4514 if(zc_readkey(KEY_C)) onShowHitboxes();
4515 if(zc_readkey(KEY_F)) onShowFFScripts();
4516 }
4517 21292 }
4518
4519
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(volkeys)
4520 {
4521 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4522
4523 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4524
4525 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4526
4527 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4528 }
4529
4530
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4391436 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4391436 if(!get_debug() || !SystemKeys || replay_is_replaying())
4531 4391436 goto bottom;
4532
4533 if(zc_readkey(KEY_D))
4534 {
4535 details = !details;
4536 rectfill(screen,0,0,319,7,BLACK);
4537 rectfill(screen,0,8,31,239,BLACK);
4538 rectfill(screen,288,8,319,239,BLACK);
4539 rectfill(screen,32,232,287,239,BLACK);
4540 }
4541
4542 if(zc_readkey(KEY_P)) Paused=!Paused;
4543
4544 //if(zc_readkey(KEY_P)) centerHero();
4545 if(zc_readkey(KEY_A))
4546 {
4547 Paused=true;
4548 Advance=true;
4549 }
4550
4551 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4552 #ifndef ALLEGRO_MACOSX
4553 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4554
4555 if(zc_readkey(KEY_F7))
4556 {
4557 Matrix(ss_speed, ss_density, 0);
4558 game_pal();
4559 }
4560 #else
4561 // The reason these are different on Mac in the first place is that
4562 // the OS doesn't let us use F9 and F10...
4563 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4564
4565 if(zc_readkey(KEY_F9))
4566 {
4567 Matrix(ss_speed, ss_density, 0);
4568 game_pal();
4569 }
4570 #endif
4571 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4572 {
4573 //change containers
4574 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4575 {
4576 //magic containers
4577 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4578 {
4579 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4580 }
4581 else
4582 {
4583 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4584 }
4585 }
4586 else
4587 {
4588 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4589 {
4590 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4591 }
4592 else
4593 {
4594 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4595 }
4596 }
4597 }
4598
4599 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4600 {
4601 //change containers
4602 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4603 {
4604 //magic containers
4605 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4606 {
4607 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4608 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4609 //heart containers
4610 }
4611 else
4612 {
4613 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4614 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4615 }
4616 }
4617 else
4618 {
4619 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4620 {
4621 game->set_magic(zc_max(game->get_magic()-1,0));
4622 }
4623 else
4624 {
4625 game->set_life(zc_max(game->get_life()-1,0));
4626 }
4627 }
4628 }
4629
4630 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4631
4632 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4633
4634 verifyBothWeapons();
4635
4636 bottom:
4637
4638
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(input_idle(true) > after_time())
4639 {
4640 Matrix(ss_speed, ss_density, 0);
4641 game_pal();
4642 }
4643 4391436 }
4644
4645 14372246 void checkQuitKeys()
4646 {
4647 #ifndef ALLEGRO_MACOSX
4648
1/2
✓ Branch 0 taken 14372246 times.
✗ Branch 1 not taken.
14372246 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4649
4650
1/2
✓ Branch 0 taken 14372246 times.
✗ Branch 1 not taken.
14372246 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4651 #else
4652 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4653
4654 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4655 #endif
4656 14372246 }
4657
4658 63876 bool CheatModifierKeys()
4659 {
4660 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4661 // to trigger cheats.
4662
1/2
✓ Branch 0 taken 63876 times.
✗ Branch 1 not taken.
63876 if (replay_is_replaying())
4663 63876 return false;
4664
4665 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4666 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4667 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4668 {
4669 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4670 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4671 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4672 {
4673 return true;
4674 }
4675 }
4676 return false;
4677 63876 }
4678
4679 //99:05:54, for some reason?
4680 #define OLDMAXTIME 21405240
4681 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4682 #define MAXTIME 1944000000
4683
4684 4329767 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4685 {
4686
2/2
✓ Branch 0 taken 4068356 times.
✓ Branch 1 taken 261411 times.
4329767 if(zcmusic!=NULL)
4687 {
4688 261411 zcmusic_poll();
4689 261411 }
4690
4691 4329767 updatescr(allowwavy);
4692
4693
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4329767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4329767 times.
4329767 while(Paused && !Advance && !Quit)
4694 {
4695 // have to call this, otherwise we'll get an infinite loop
4696 syskeys();
4697 if(allowF6Script)
4698 {
4699 FFCore.runF6Engine();
4700 }
4701 throttleFPS();
4702
4703 #ifdef _WIN32
4704
4705 if(use_dwm_flush)
4706 {
4707 do_DwmFlush();
4708 }
4709
4710 #endif
4711
4712 // to keep music playing
4713 if(zcmusic!=NULL)
4714 {
4715 zcmusic_poll();
4716 }
4717
4718 update_hw_screen();
4719 }
4720
4721
2/2
✓ Branch 0 taken 4329744 times.
✓ Branch 1 taken 23 times.
4329767 if(Quit)
4722 23 return;
4723
4724
3/4
✓ Branch 0 taken 4270247 times.
✓ Branch 1 taken 59497 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4270247 times.
4329744 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4725 4270247 game->change_time(1);
4726
4727 4329744 Advance=false;
4728
4729
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4329738 times.
4329744 if (replay_is_active())
4730 {
4731
2/2
✓ Branch 0 taken 1270457 times.
✓ Branch 1 taken 3059281 times.
4329738 if (replay_get_version() >= 3)
4732 3059281 replay_poll();
4733
4734 // Replay compatability.
4735
4/4
✓ Branch 0 taken 909086 times.
✓ Branch 1 taken 3420652 times.
✓ Branch 2 taken 808551 times.
✓ Branch 3 taken 100535 times.
4329738 if (replay_get_version() >= 6 && replay_get_version() < 8)
4736 100535 replay_peek_input();
4737 4329738 }
4738
4739 4329744 update_keys();
4740
4741 4329744 ++frame;
4742
4743
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4329738 times.
4329744 if (replay_is_replaying())
4744 4329738 replay_do_cheats();
4745 4329744 syskeys();
4746
4747 // The mouse variables can change from the mouse thread at anytime during a frame,
4748 // so save the result at the start so that replaying is consistent.
4749 4329744 script_mouse_x = gui_mouse_x();
4750 4329744 script_mouse_y = gui_mouse_y();
4751 4329744 script_mouse_z = mouse_z;
4752 4329744 script_mouse_b = mouse_b;
4753
4754 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4755 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4756 // approach here means it doesn't matter which call adds the cheat.
4757 4329744 cheats_execute_queued();
4758
4759
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4329738 times.
4329744 if (replay_is_replaying())
4760 4329738 replay_peek_quit();
4761
2/2
✓ Branch 0 taken 4329730 times.
✓ Branch 1 taken 14 times.
4329744 if (GameFlags & GAMEFLAG_TRYQUIT)
4762 14 replay_step_quit(0);
4763
2/2
✓ Branch 0 taken 1466 times.
✓ Branch 1 taken 4328278 times.
4329744 if(allowF6Script)
4764 {
4765 4328278 FFCore.runF6Engine();
4766 4328278 }
4767
2/2
✓ Branch 0 taken 4329613 times.
✓ Branch 1 taken 131 times.
4329744 if (Quit)
4768 131 replay_step_quit(Quit);
4769 // Someday... maybe install a Turbo button here?
4770 4329744 throttleFPS();
4771
4772 #ifdef _WIN32
4773
4774 if(use_dwm_flush)
4775 {
4776 do_DwmFlush();
4777 }
4778
4779 #endif
4780
4781 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4782
2/2
✓ Branch 0 taken 6446 times.
✓ Branch 1 taken 4323298 times.
4329744 if(sfxcleanup)
4783 4323298 sfx_cleanup();
4784 4329767 }
4785
4786 12 void zapout()
4787 {
4788 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4789 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4790
4791 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4792 12 script_drawing_commands.Clear();
4793
4794 // zap out
4795
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=1; i<=24; i++)
4796 {
4797 288 draw_fuzzy(i);
4798 288 syskeys();
4799 288 advanceframe(true);
4800
4801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4802 {
4803 break;
4804 }
4805 288 }
4806 12 }
4807
4808 12 void zapin()
4809 {
4810 12 FFCore.warpScriptCheck();
4811 12 draw_screen(tmpscr);
4812 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4813 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4814 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4815
4816 // zap out
4817 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4818
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=24; i>=1; i--)
4819 {
4820 288 draw_fuzzy(i);
4821 288 syskeys();
4822 288 advanceframe(true);
4823
4824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4825 {
4826 break;
4827 }
4828 288 }
4829 12 }
4830
4831
4832 23 void wavyout(bool showhero)
4833 {
4834 23 draw_screen(tmpscr, showhero);
4835 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4836
4837 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4838 23 clear_to_color(wavebuf,0);
4839 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4840
4841 static PALETTE wavepal;
4842
4843 int32_t ofs;
4844 23 int32_t amplitude=8;
4845
4846 23 int32_t wavelength=4;
4847 23 double palpos=0, palstep=4, palstop=126;
4848
4849 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4850
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4851 {
4852
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4853 {
4854 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4855 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4856 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4857 247296 }
4858
4859 966 palpos+=palstep;
4860
4861
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4862 {
4863 966 hw_palette = &wavepal;
4864 966 update_hw_pal = true;
4865 966 }
4866 else
4867 {
4868 hw_palette = &RAMpal;
4869 update_hw_pal = true;
4870 }
4871
4872
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4873 {
4874
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4875 {
4876 41545728 ofs=0;
4877
4878
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4879 {
4880 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4881 10139136 }
4882
4883 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4884 41545728 }
4885 162288 }
4886
4887 966 syskeys();
4888 966 advanceframe(true);
4889
4890 // animate_combos();
4891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4892 break;
4893 966 }
4894
4895 23 destroy_bitmap(wavebuf);
4896 23 }
4897
4898 23 void wavyin()
4899 {
4900 23 draw_screen(tmpscr);
4901 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4902
4903 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4904 23 clear_to_color(wavebuf,0);
4905 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4906
4907 static PALETTE wavepal;
4908
4909 //Breaks dark rooms.
4910 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4911 /*
4912 loadfullpal();
4913 loadlvlpal(DMaps[currdmap].color);
4914 ringcolor(false);
4915 */
4916 23 refreshpal=false;
4917 int32_t ofs;
4918 23 int32_t amplitude=8;
4919 23 int32_t wavelength=4;
4920 23 double palpos=168, palstep=4, palstop=126;
4921
4922 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4923
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4924 {
4925
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4926 {
4927 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4928 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4929 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4930 247296 }
4931
4932 966 palpos-=palstep;
4933
4934
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4935 {
4936 966 hw_palette = &wavepal;
4937 966 update_hw_pal = true;
4938 966 }
4939 else
4940 {
4941 hw_palette = &RAMpal;
4942 update_hw_pal = true;
4943 }
4944
4945
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4946 {
4947
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4948 {
4949 41545728 ofs=0;
4950
4951
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4952 {
4953 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4954 10386432 }
4955
4956 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4957 41545728 }
4958 162288 }
4959
4960 966 syskeys();
4961 966 advanceframe(true);
4962 // animate_combos();
4963
4964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4965 break;
4966 966 }
4967
4968 23 destroy_bitmap(wavebuf);
4969 23 }
4970
4971 1252 void blackscr(int32_t fcnt,bool showsubscr)
4972 {
4973 1252 reset_pal_cycling();
4974 1252 script_drawing_commands.Clear();
4975
4976 1252 FFCore.warpScriptCheck();
4977 1252 bool showtime = game->should_show_time();
4978
2/2
✓ Branch 0 taken 1252 times.
✓ Branch 1 taken 37490 times.
38742 while(fcnt>0)
4979 {
4980 37490 clear_bitmap(framebuf);
4981
4982
2/2
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 28130 times.
37490 if(showsubscr)
4983 {
4984 28130 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4985
3/4
✓ Branch 0 taken 28130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 27380 times.
28130 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4986 {
4987 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4988 750 }
4989 28130 }
4990
4991 37490 syskeys();
4992 37490 advanceframe(true);
4993
4994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37490 times.
37490 if(Quit)
4995 break;
4996
4997 37490 --fcnt;
4998 }
4999 1252 }
5000
5001 308 void openscreen(int32_t shape)
5002 {
5003 308 reset_pal_cycling();
5004 308 black_opening_count=0;
5005
5006
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 210 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
308 if(COOLSCROLL || shape>-1)
5007 {
5008 210 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5009 210 return;
5010 }
5011 else
5012 {
5013 98 Hero.setDontDraw(true);
5014 98 show_subscreen_dmap_dots=false;
5015 98 show_subscreen_numbers=false;
5016 // show_subscreen_items=false;
5017 98 show_subscreen_life=false;
5018 }
5019
5020 98 int32_t x=128;
5021
5022 98 FFCore.warpScriptCheck();
5023
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5024 {
5025 7840 draw_screen(tmpscr);
5026 //? draw_screen already draws the subscreen -DD
5027 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5028 7840 x=128-(((i*128/80)/8)*8);
5029
5030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5031 {
5032 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5033 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5034 7840 }
5035
5036 // x=((80-i)/2)*4;
5037 /*
5038 --x;
5039 switch(++c)
5040 {
5041 case 5: c=0;
5042 case 0:
5043 case 2:
5044 case 3: --x; break;
5045 }
5046 */
5047 7840 syskeys();
5048 7840 advanceframe(true);
5049
5050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5051 {
5052 break;
5053 }
5054 7840 }
5055
5056 98 Hero.setDontDraw(false);
5057 98 show_subscreen_items=true;
5058 98 show_subscreen_dmap_dots=true;
5059 308 }
5060
5061 void closescreen(int32_t shape)
5062 {
5063 reset_pal_cycling();
5064 black_opening_count=0;
5065
5066 if(COOLSCROLL || shape>-1)
5067 {
5068 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5069 return;
5070 }
5071 else
5072 {
5073 Hero.setDontDraw(true);
5074 show_subscreen_dmap_dots=false;
5075 show_subscreen_numbers=false;
5076 // show_subscreen_items=false;
5077 show_subscreen_life=false;
5078 }
5079
5080 int32_t x=128;
5081
5082 FFCore.warpScriptCheck();
5083 for(int32_t i=79; i>=0; --i)
5084 {
5085 draw_screen(tmpscr);
5086 //? draw_screen already draws the subscreen -DD
5087 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5088 x=128-(((i*128/80)/8)*8);
5089
5090 if(x>0)
5091 {
5092 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5093 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5094 }
5095
5096 // x=((80-i)/2)*4;
5097 /*
5098 --x;
5099 switch(++c)
5100 {
5101 case 5: c=0;
5102 case 0:
5103 case 2:
5104 case 3: --x; break;
5105 }
5106 */
5107 syskeys();
5108 advanceframe(true);
5109
5110 if(Quit)
5111 {
5112 break;
5113 }
5114 }
5115
5116 Hero.setDontDraw(false);
5117 show_subscreen_items=true;
5118 show_subscreen_dmap_dots=true;
5119 }
5120
5121 84 int32_t TriforceCount()
5122 {
5123 84 int32_t c=0;
5124
5125
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 84 times.
756 for(int32_t i=1; i<=8; i++)
5126
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 374 times.
1046 if(game->lvlitems[i]&liTRIFORCE)
5127 374 ++c;
5128
5129 84 return c;
5130 }
5131
5132 int32_t onCustomGame()
5133 {
5134 int32_t file = getsaveslot();
5135
5136 if(file < 0)
5137 return D_O_K;
5138
5139 bool ret = (custom_game(file)!=0);
5140 return ret ? D_CLOSE : D_O_K;
5141 }
5142
5143 int32_t onContinue()
5144 {
5145 return D_CLOSE;
5146 }
5147
5148 int32_t onEsc() // Unused?? -L
5149 {
5150 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5151 }
5152
5153 int32_t onVsync()
5154 {
5155 Throttlefps = !Throttlefps;
5156 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5157 return D_O_K;
5158 }
5159
5160 int32_t onWinPosSave()
5161 {
5162 SaveWinPos = !SaveWinPos;
5163 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5164 return D_O_K;
5165 }
5166
5167 int32_t onClickToFreeze()
5168 {
5169 ClickToFreeze = !ClickToFreeze;
5170 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5171 return D_O_K;
5172 }
5173
5174 int32_t OnSaveZCConfig()
5175 {
5176 if(jwin_alert3(
5177 "Save Configuration",
5178 "Are you sure that you wish to save your present configuration settings?",
5179 "This will overwrite your prior settings!",
5180 NULL,
5181 "&Yes",
5182 "&No",
5183 NULL,
5184 'y',
5185 'n',
5186 0,
5187 lfont) == 1)
5188 {
5189 save_game_configs();
5190 return D_O_K;
5191 }
5192 else return D_O_K;
5193 }
5194
5195 int32_t OnnClearQuestDir()
5196 {
5197 if(jwin_alert3(
5198 "Clear Current Directory Cache",
5199 "Are you sure that you wish to clear the current cached directory?",
5200 "This will default the current directory to the ROOT for this instance of ZC Player!",
5201 NULL,
5202 "&Yes",
5203 "&No",
5204 NULL,
5205 'y',
5206 'n',
5207 0,
5208 lfont) == 1)
5209 {
5210 zc_set_config("zeldadx","win_qst_dir","");
5211 flush_config_file();
5212 strcpy(qstdir,"");
5213 #ifdef __EMSCRIPTEN__
5214 em_sync_fs();
5215 #endif
5216 return D_O_K;
5217 }
5218 else return D_O_K;
5219 }
5220
5221
5222 int32_t onConsoleZASM()
5223 {
5224 if ( !zasm_debugger )
5225 {
5226 AlertDialog("WARNING: ZASM Debugger",
5227 "Enabling this will open the ZASM Debugger Console"
5228 "\nThis will likely grind ZC to a halt with lag."
5229 "\nTo make any use of this, it is suggested that you read"
5230 "\nthe documentation for 'void Breakpoint(char[] string);'"
5231 " in 'ZScript_Additions.txt'"
5232 "\nThis is not recommended for normal users,"
5233 " and is only intended for ZC developers,"
5234 "\nor quest developers coding directly in ZASM"
5235 "\nAre you sure that you wish to open the ZASM Debugger?",
5236 [&](bool ret,bool)
5237 {
5238 if(ret)
5239 {
5240 FFCore.ZASMPrint(true);
5241 }
5242 }).show();
5243 return D_O_K;
5244 }
5245 else
5246 {
5247 FFCore.ZASMPrint(false);
5248 return D_O_K;
5249 }
5250 }
5251
5252
5253 int32_t onConsoleZScript()
5254 {
5255 if ( !zscript_debugger )
5256 {
5257 AlertDialog("ZScript Debugger",
5258 "Enabling this will open the ZScript Debugger Console"
5259 "\nThis will display any messages logged by scripts,"
5260 " including script errors."
5261 "\nAre you sure that you wish to open the ZScript Debugger?",
5262 [&](bool ret,bool)
5263 {
5264 if(ret)
5265 {
5266 FFCore.ZScriptConsole(true);
5267 }
5268 }).show();
5269 return D_O_K;
5270 }
5271 else
5272 {
5273 FFCore.ZScriptConsole(false);
5274 return D_O_K;
5275 }
5276 }
5277
5278 int32_t onClrConsoleOnLoad()
5279 {
5280 clearConsoleOnLoad = !clearConsoleOnLoad;
5281 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5282 return D_O_K;
5283 }
5284
5285
5286 int32_t onFrameSkip()
5287 {
5288 FrameSkip = !FrameSkip;
5289 return D_O_K;
5290 }
5291
5292 int32_t onSaveDragResize()
5293 {
5294 SaveDragResize = !SaveDragResize;
5295 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5296 return D_O_K;
5297 }
5298
5299 int32_t onDragAspect()
5300 {
5301 DragAspect = !DragAspect;
5302 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5303 return D_O_K;
5304 }
5305
5306 int32_t onTransLayers()
5307 {
5308 TransLayers = !TransLayers;
5309 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5310 return D_O_K;
5311 }
5312
5313 int32_t onNESquit()
5314 {
5315 NESquit = !NESquit;
5316 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5317 return D_O_K;
5318 }
5319
5320 int32_t onVolKeys()
5321 {
5322 volkeys = !volkeys;
5323 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5324 return D_O_K;
5325 }
5326
5327 int32_t onShowFPS()
5328 {
5329 ShowFPS = !ShowFPS;
5330 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5331 return D_O_K;
5332 }
5333
5334 518189448 bool is_Fkey(int32_t k)
5335 {
5336
2/2
✓ Branch 0 taken 52697232 times.
✓ Branch 1 taken 465492216 times.
518189448 switch(k)
5337 {
5338 case KEY_F1:
5339 case KEY_F2:
5340 case KEY_F3:
5341 case KEY_F4:
5342 case KEY_F5:
5343 case KEY_F6:
5344 case KEY_F7:
5345 case KEY_F8:
5346 case KEY_F9:
5347 case KEY_F10:
5348 case KEY_F11:
5349 case KEY_F12:
5350 52697232 return true;
5351 }
5352
5353 465492216 return false;
5354 518189448 }
5355
5356 void kb_getkey(DIALOG *d)
5357 {
5358 d->flags|=D_SELECTED;
5359
5360 scare_mouse();
5361 jwin_button_proc(MSG_DRAW,d,0);
5362 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5363 // text_mode(vc(11));
5364 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5365 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5366 unscare_mouse();
5367
5368 update_hw_screen(true);
5369
5370 clear_keybuf();
5371 int32_t k = next_press_key();
5372 clear_keybuf();
5373
5374 //shnarf
5375 //47=f1
5376 //59=esc
5377 if(k>0 && k<123 && !((k>46)&&(k<60)))
5378 *((int32_t*)d->dp3) = k;
5379
5380
5381 d->flags&=~D_SELECTED;
5382 }
5383
5384
5385 //Used by all keyboard key settings dialogues.
5386 void kb_clearjoystick(DIALOG *d)
5387 {
5388 d->flags|=D_SELECTED;
5389
5390 scare_mouse();
5391 jwin_button_proc(MSG_DRAW,d,0);
5392 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5393 // text_mode(vc(11));
5394 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5395 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5396 unscare_mouse();
5397
5398 update_hw_screen(true);
5399
5400 clear_keybuf();
5401 int32_t k = next_press_key();
5402 clear_keybuf();
5403
5404 //shnarf
5405 //47=f1
5406 //59=esc
5407 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5408 // *((int32_t*)d->dp3) = k;
5409 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5410
5411
5412 d->flags&=~D_SELECTED;
5413 }
5414
5415 //Clears key to 0.
5416 //Used by all keyboard key settings dialogues.
5417 void kb_clearkey(DIALOG *d)
5418 {
5419 d->flags|=D_SELECTED;
5420
5421 scare_mouse();
5422 jwin_button_proc(MSG_DRAW,d,0);
5423 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5424 // text_mode(vc(11));
5425 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5426 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5427 unscare_mouse();
5428
5429 update_hw_screen(true);
5430
5431 clear_keybuf();
5432 int32_t k = next_press_key();
5433 clear_keybuf();
5434
5435 //shnarf
5436 //47=f1
5437 //59=esc
5438 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5439 // *((int32_t*)d->dp3) = k;
5440 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5441
5442
5443 d->flags&=~D_SELECTED;
5444 }
5445
5446
5447 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5448 {
5449 switch(msg)
5450 {
5451 case MSG_KEY:
5452 case MSG_CLICK:
5453
5454 kb_clearjoystick(d);
5455
5456 while(gui_mouse_b())
5457 {
5458 clear_keybuf();
5459 rest(1);
5460 }
5461
5462 return D_REDRAW;
5463 }
5464
5465 return jwin_button_proc(msg,d,c);
5466 }
5467
5468 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5469 {
5470 switch(msg)
5471 {
5472 case MSG_KEY:
5473 case MSG_CLICK:
5474
5475 kb_getkey(d);
5476
5477 while(gui_mouse_b()) {
5478 clear_keybuf();
5479 rest(1);
5480 }
5481
5482 return D_REDRAW;
5483 }
5484
5485 return jwin_button_proc(msg,d,c);
5486 }
5487
5488 //Only used in keyboard settings dialogues to clear keys.
5489 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5490 {
5491 switch(msg)
5492 {
5493 case MSG_KEY:
5494 case MSG_CLICK:
5495
5496 kb_clearkey(d);
5497
5498 while(gui_mouse_b()) {
5499 clear_keybuf();
5500 rest(1);
5501 }
5502
5503 return D_REDRAW;
5504 }
5505
5506 return jwin_button_proc(msg,d,c);
5507 }
5508
5509 void j_getbtn(DIALOG *d)
5510 {
5511 d->flags|=D_SELECTED;
5512 scare_mouse();
5513 jwin_button_proc(MSG_DRAW,d,0);
5514 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5515 // text_mode(vc(11));
5516 int32_t y = gui_bmp->h/2 - 12;
5517 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5518 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5519 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5520 unscare_mouse();
5521
5522 update_hw_screen(true);
5523
5524 int32_t b = next_press_btn();
5525
5526 if(b>=0)
5527 *((int32_t*)d->dp3) = b;
5528
5529 d->flags&=~D_SELECTED;
5530
5531 if (player)
5532 player->joy_on = TRUE;
5533 }
5534
5535 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5536 {
5537 switch(msg)
5538 {
5539 case MSG_KEY:
5540 case MSG_CLICK:
5541
5542 j_getbtn(d);
5543
5544 while(gui_mouse_b()) {
5545 rest(1);
5546 clear_keybuf();
5547 }
5548
5549 return D_REDRAW;
5550 }
5551
5552 return jwin_button_proc(msg,d,c);
5553 }
5554
5555 //shnarf
5556 const char *key_str[] =
5557 {
5558 "(none) ", "a ", "b ", "c ",
5559 "d ", "e ", "f ", "g ",
5560 "h ", "i ", "j ", "k ",
5561 "l ", "m ", "n ", "o ",
5562 "p ", "q ", "r ", "s ",
5563 "t ", "u ", "v ", "w ",
5564 "x ", "y ", "z ", "0 ",
5565 "1 ", "2 ", "3 ", "4 ",
5566 "5 ", "6 ", "7 ", "8 ",
5567 "9 ", "num 0 ", "num 1 ", "num 2 ",
5568 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5569 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5570 "f2 ", "f3 ", "f4 ", "f5 ",
5571 "f6 ", "f7 ", "f8 ", "f9 ",
5572 "f10 ", "f11 ", "f12 ", "esc ",
5573 "~ ", "- ", "= ", "backspace ",
5574 "tab ", "{ ", "} ", "enter ",
5575 ": ", "quote ", "\\ ", "\\ (2) ",
5576 ", ", ". ", "/ ", "space ",
5577 "insert ", "delete ", "home ", "end ",
5578 "page up ", "page down ", "left ", "right ",
5579 "up ", "down ", "num / ", "num * ",
5580 "num - ", "num + ", "num delete ", "num enter ",
5581 "print screen ", "pause ", "abnt c1 ", "yen ",
5582 "kana ", "convert ", "no convert ", "at ",
5583 "circumflex ", ": (2) ", "kanji ", "num = ",
5584 "back quote ", "; ", "command ", "unknown (0) ",
5585 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5586 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5587 "right shift ", "left control ", "right control", "alt ",
5588 "alt gr ", "left win ", "right win ", "menu ",
5589 "scroll lock ", "number lock ", "caps lock ", "MAX"
5590 };
5591
5592
5593 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5594 //extern int32_t zcmusic_bufsz;
5595
5596 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5597 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5598
5599 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5600 {
5601 //these are here to bypass compiler warnings about unused arguments
5602 c=c;
5603
5604 if(msg==MSG_DRAW)
5605 {
5606 switch(d->w)
5607 {
5608 case 0:
5609 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5610 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5611 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5612 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5613 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5614 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5615 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5616 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5617 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5618 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5619 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5620 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5621 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5622 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5623 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5624 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5625 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5626 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5627 break;
5628
5629 case 1:
5630 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5631 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5632 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5633 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5634 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5635 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5636 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5637 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5638 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5639 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5640 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5641 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5642 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5643 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5644 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5645 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5646 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5647 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5648 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5649 break;
5650
5651 case 2:
5652 sprintf(str_a," %3d",midi_volume);
5653 sprintf(str_b," %3d",digi_volume);
5654 sprintf(str_l," %3d",emusic_volume);
5655 sprintf(str_m," %3dKB",zcmusic_bufsz);
5656 sprintf(str_r," %3d",sfx_volume);
5657 strcpy(str_s,pan_str[pan_style]);
5658 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5659 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5660 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5661 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5662 break;
5663 }
5664 }
5665
5666 return D_O_K;
5667 }
5668
5669 int32_t set_vol(void *dp3, int32_t d2)
5670 {
5671 switch(((int32_t*)dp3)[0])
5672 {
5673 case 0:
5674 midi_volume = zc_min(d2<<3,255);
5675 break;
5676
5677 case 1:
5678 digi_volume = zc_min(d2<<3,255);
5679 break;
5680
5681 case 2:
5682 emusic_volume = zc_min(d2<<3,255);
5683 break;
5684
5685 case 3:
5686 sfx_volume = zc_min(d2<<3,255);
5687 break;
5688 }
5689
5690 scare_mouse();
5691 // text_mode(vc(11));
5692 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5693 unscare_mouse();
5694 return D_O_K;
5695 }
5696
5697 int32_t set_pan(void *dp3, int32_t d2)
5698 {
5699 pan_style = vbound(d2,0,3);
5700 scare_mouse();
5701 // text_mode(vc(11));
5702 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5703 unscare_mouse();
5704 return D_O_K;
5705 }
5706
5707 int32_t set_buf(void *dp3, int32_t d2)
5708 {
5709 scare_mouse();
5710 // text_mode(vc(11));
5711 zcmusic_bufsz = d2 + 1;
5712 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5713 unscare_mouse();
5714 return D_O_K;
5715 }
5716
5717 static int32_t gamepad_btn_list[] =
5718 {
5719 6,
5720 7,8,9,10,11,12,13,14,15,16,17,
5721 18,19,20,21,22,23,24,25,26,27,28,
5722 29,30,31,32,33,34,35,36,37,38,39,
5723 -1
5724 };
5725
5726 static int32_t gamepad_dirs_list[] =
5727 {
5728 40,41,42,43,
5729 44,45,46,47,
5730 48,49,50,51,
5731 52,53,54,55,
5732 56,
5733 -1
5734 };
5735
5736 static TABPANEL gamepad_tabs[] =
5737 {
5738 // (text)
5739 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5740 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5741 { NULL, 0, NULL, 0, NULL }
5742 };
5743
5744 static DIALOG gamepad_dlg[] =
5745 {
5746 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5747 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5748 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5749 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5750 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5751 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5752 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5753 // 6
5754 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5755 // 7
5756 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5757 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5758 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5759 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5760 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5761 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5762 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5763 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5764 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5765 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5766 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5767 // 18
5768 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5769 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5770 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5771 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5772 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5773 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5774 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5775 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5776 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5777 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5778 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5779 // 29
5780 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5781 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5782 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5783 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5784 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5785 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5786 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5787 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5788 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5789 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5790 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5791 // 40
5792 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5793 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5794 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5795 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5796 // 44
5797 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5798 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5799 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5800 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5801 // 48
5802 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5803 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5804 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5805 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5806 // 52
5807 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5808 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5809 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5810 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5811 // 56
5812 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5813 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5814 };
5815
5816 static int32_t keyboard_keys_list[] =
5817 {
5818 6,7,8,9,10,
5819 11,12,13,14,15,16,17,18,19,20,
5820 21,22,23,24,25,26,27,28,29,30,
5821 31,32,33,34,35,36,37,38,39,40,
5822 -1
5823 };
5824
5825 static int32_t keyboard_dirs_list[] =
5826 {
5827 41,42,43,44,
5828 45,46,47,48,
5829 49,50,51,52,
5830 53,54,55,56,
5831 -1
5832 };
5833
5834 static int32_t keyboard_mods_list[] =
5835 {
5836 57,58,59,60,
5837 61,62,63,64,
5838 65,66,67,68,
5839 69,70,71,72,
5840 -1
5841 };
5842
5843 static TABPANEL keyboard_control_tabs[] =
5844 {
5845 // (text)
5846 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5847 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5848 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5849 { NULL, 0, NULL, 0, NULL }
5850 };
5851
5852 static DIALOG keyboard_control_dlg[] =
5853 {
5854 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5855 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5856 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5857 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5858 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5859 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5860 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5861 // Keys
5862 // 6
5863 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5864 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5865 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5866 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5867 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5868 // 11
5869 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5870 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5871 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5872 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5873 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5874 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5875 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5876 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5877 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5878 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5879 // 21
5880 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5881 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5882 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5883 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5884 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5885 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5886 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5887 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5888 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5889 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5890 // 31
5891 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5892 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5893 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5894 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5895 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5896 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5897 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5898 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5899 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5900 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5901 // Dirs
5902 // 41
5903 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5904 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5905 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5906 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5907 // 45
5908 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5909 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5910 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5911 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5912 // 49
5913 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5914 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5915 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5916 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5917 // 53
5918 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5919 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5920 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5921 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5922 // Mods
5923 // 57
5924 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5925 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5926 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5927 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5928 // 61
5929 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5930 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5931 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5932 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5933 // 65
5934 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5935 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5936 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5937 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5938 // 69
5939 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5940 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5941 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5942 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5943 // 73
5944 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5945 };
5946
5947 /*
5948 int32_t midi_dp[3] = {0,147,104};
5949 int32_t digi_dp[3] = {1,147,120};
5950 int32_t pan_dp[3] = {0,147,136};
5951 int32_t buf_dp[3] = {0,147,152};
5952 */
5953 int32_t midi_dp[3] = {0,0,0};
5954 int32_t digi_dp[3] = {1,0,0};
5955 int32_t emus_dp[3] = {2,0,0};
5956 int32_t buf_dp[3] = {0,0,0};
5957 int32_t sfx_dp[3] = {3,0,0};
5958 int32_t pan_dp[3] = {0,0,0};
5959
5960 static DIALOG sound_dlg[] =
5961 {
5962 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5963 24 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5964 24 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5965 24 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5966 24 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5967 24 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5968 24 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5969 24 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5970 24 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5971 24 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5972 24 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5973 // 10
5974 24 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5975 24 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5976 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5977 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5978 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5979 24 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5980 24 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5981 24 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5982 24 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5983 24 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5984 //20
5985 24 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5986 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5987 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5988 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5989 24 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5990 24 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5991 24 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5992 24 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5993 24 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5994 24 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5995 //30
5996 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5997 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5998 24 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5999 24 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6000 };
6001
6002 char zc_builddate[80];
6003 char zc_aboutstr[80];
6004
6005 static DIALOG about_dlg[] =
6006 {
6007 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6008 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6009 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6010 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6011 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6012 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6013 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6014 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6015 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6016 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6017 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6018 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6019 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6020 };
6021
6022
6023 static DIALOG quest_dlg[] =
6024 {
6025 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6026 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6027 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6028 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6029 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6030 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6031 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
6032 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6033 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6034 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6035 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6036 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6037 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6038 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6039 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6040 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6041 };
6042
6043 static DIALOG triforce_dlg[] =
6044 {
6045 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6046 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6047 // 1
6048 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6049 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6050 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6051 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6052 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6053 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6054 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6055 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6056 // 9
6057 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6058 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6059 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6060 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6061 };
6062
6063 /*static DIALOG equip_dlg[] =
6064 {
6065 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6066 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6067 // 1
6068 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6069 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6070 // 3
6071 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6072 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6073 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6074 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6075 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6076 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6077 // 9
6078 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6079 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6080 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6081 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6082 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6083 // 14
6084 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6085 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6086 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6087 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6088 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6089 // 19
6090 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6091 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6092 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6093 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6094 // 23
6095 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6096 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6097 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6098 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6099 // 27
6100 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6101 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6102 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6103 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6104 // 31
6105 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6106 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6107 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6108 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6109 // 35
6110 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6111 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6112 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6113 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6114 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6115 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6116 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6117 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6118 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6119 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6120 };
6121
6122 static DIALOG items_dlg[] =
6123 {
6124 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6125 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6126 //1
6127 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6128 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6129 // 3
6130 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6131 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6132 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6133 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6134 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6135 // 8
6136 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6137 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6138 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6139 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6140 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6141 // 13
6142 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6143 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6144 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6145 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6146 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6147 // 18
6148 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6149 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6150 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6151 // 21
6152 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6153 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6154 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6155 // 24
6156 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6157 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6158 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6159 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6160 // 28
6161 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6162 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6163 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6164 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6165 // 32
6166 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6167 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6168 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6169 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6170 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6171 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6172 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6173 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6174 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6175 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6176 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6177 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6178 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6179 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6180 //45
6181 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6182 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6183 };*/
6184
6185
6186
6187 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6188 {
6189 go();
6190 int32_t ret=0;
6191 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6192 comeback();
6193 return ret != 0;
6194 }
6195
6196
6197 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6198 {
6199 if(def!=modulepath)
6200 strcpy(modulepath,def);
6201
6202 if(!usefilename)
6203 {
6204 int32_t i=(int32_t)strlen(modulepath);
6205
6206 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6207 modulepath[i--]=0;
6208 }
6209
6210 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6211 int32_t ret=0;
6212 int32_t sel=0;
6213
6214 if(list==NULL)
6215 {
6216 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6217 }
6218 else
6219 {
6220 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6221 }
6222
6223 return ret!=0;
6224 }
6225
6226 //The Dialogue that loads a ZMOD Module File
6227 int32_t zc_load_zmod_module_file()
6228 {
6229 if ( Playing )
6230 {
6231 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6232 return -1;
6233 }
6234 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6235 return D_CLOSE;
6236
6237 FILE *tempmodule = fopen(modulepath,"r");
6238
6239 if(tempmodule == NULL)
6240 {
6241 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6242 return -1;
6243 }
6244
6245
6246 //Set the module path:
6247 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6248 strcpy(moduledata.module_name, modulepath);
6249 al_trace("New Module Path is: %s \n", moduledata.module_name);
6250 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6251 zcm.init(true); //Load the module values.
6252 moduledata.refresh_title_screen = 1;
6253 // refresh_select_screen = 1;
6254 build_biic_list();
6255 return D_O_K;
6256 }
6257
6258 static DIALOG module_info_dlg[] =
6259 {
6260 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6261
6262
6263 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6264 //1
6265 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6266 //2
6267 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6268 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6269 //4
6270 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6271 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6272 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6273 //7
6274
6275 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6276 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6277 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6278 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6279 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6280 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6281 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6282 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6283 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6284
6285 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6286 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6287 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6288 };
6289
6290 void about_zcplayer_module(const char *prompt,int32_t initialval)
6291 {
6292
6293 module_info_dlg[0].dp2 = lfont;
6294 if ( moduledata.moduletitle[0] != 0 )
6295 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6296
6297 if ( moduledata.moduleauthor[0] != 0 )
6298 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6299
6300 if ( moduledata.moduleinfo0[0] != 0 )
6301 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6302 if ( moduledata.moduleinfo1[0] != 0 )
6303 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6304 if ( moduledata.moduleinfo2[0] != 0 )
6305 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6306 if ( moduledata.moduleinfo3[0] != 0 )
6307 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6308 if ( moduledata.moduleinfo4[0] != 0 )
6309 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6310
6311 char module_date[255];
6312 memset(module_date, 0, sizeof(module_date));
6313 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6314 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6315
6316
6317
6318 char module_vers[255];
6319 memset(module_vers, 0, sizeof(module_vers));
6320 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6321
6322
6323 //sprintf(tilecount,"%d",1);
6324
6325 char module_build[255];
6326 memset(module_build, 0, sizeof(module_build));
6327 if ( moduledata.modbeta )
6328 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6329 else
6330 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6331
6332 module_info_dlg[12].dp = (char*)module_date;
6333 module_info_dlg[13].dp = (char*)module_vers;
6334 module_info_dlg[14].dp = (char*)module_build;
6335
6336 if(is_large)
6337 large_dialog(module_info_dlg);
6338
6339 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6340 jwin_center_dialog(module_info_dlg);
6341
6342
6343 }
6344
6345 int32_t onAbout_ZCP_Module()
6346 {
6347 about_zcplayer_module("About Module (.zmod)", 0);
6348 return D_O_K;
6349 }
6350
6351 //New Modules Menu for 2.55+
6352 static MENU zcmodule_menu[] =
6353 {
6354 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6355 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6356
6357 { NULL, NULL, NULL, 0, NULL }
6358 };
6359
6360 int32_t onToggleRecordingNewSaves()
6361 {
6362 if (zc_get_config("zeldadx", "replay_new_saves", false))
6363 {
6364 zc_set_config("zeldadx", "replay_new_saves", false);
6365 }
6366 else
6367 {
6368 zc_set_config("zeldadx", "replay_new_saves", true);
6369 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6370 NULL,NULL,"OK",NULL,13,27,lfont);
6371 }
6372 return D_O_K;
6373 }
6374
6375 int32_t onToggleSnapshotAllFrames()
6376 {
6377 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6378 return D_O_K;
6379 }
6380
6381 int32_t onStopReplayOrRecord()
6382 {
6383 if (replay_is_replaying())
6384 {
6385 replay_quit();
6386 }
6387 else if (replay_get_mode() == ReplayMode::Record)
6388 {
6389 if (!replay_get_meta_bool("test_mode"))
6390 {
6391 jwin_alert("Recording", "You cannot stop recording a save file.",
6392 NULL,NULL,"OK",NULL,13,27,lfont);
6393 return D_CLOSE;
6394 }
6395
6396 if (jwin_alert("Stop Recording",
6397 "Save replay to disk and stop recording?",
6398 "This will stop the recording.",
6399 NULL,
6400 "Yes","No",13,27,lfont) != 1)
6401 return D_CLOSE;
6402
6403 replay_save();
6404 replay_stop();
6405 }
6406 return D_O_K;
6407 }
6408
6409 static int32_t handle_on_load_replay(ReplayMode mode)
6410 {
6411 if (Playing)
6412 {
6413 if (jwin_alert("Replay - Warning!",
6414 "Loading a replay will exit the current game.",
6415 "All unsaved progress will be lost.",
6416 "Do you wish to continue?",
6417 "Yes","No",13,27,lfont) != 1)
6418 return D_CLOSE;
6419 }
6420
6421 std::string mode_string = replay_mode_to_string(mode);
6422 mode_string[0] = std::toupper(mode_string[0]);
6423
6424 std::string line_1 = "Select a replay file to play back.";
6425 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6426 std::string line_3 = "You can stop the replay and take over manually any time.";
6427 if (mode == ReplayMode::Update)
6428 {
6429 line_1 = "Select a replay file to update.";
6430 line_2 = "WARNING: be sure to back up the zplay file";
6431 line_3 = "and verify that the updated replay works as expected!";
6432 }
6433
6434 if (jwin_alert(mode_string.c_str(),
6435 line_1.c_str(),
6436 line_2.c_str(),
6437 line_3.c_str(),
6438 "OK","Nevermind",13,27,lfont) == 1)
6439 {
6440 char replay_path[2048];
6441 strcpy(replay_path, "replays/");
6442 if (jwin_file_select_ex(
6443 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6444 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6445 return D_CLOSE;
6446
6447 replay_quit();
6448 load_replay_file_deferred(mode, replay_path);
6449 Quit = qRESET;
6450 return D_CLOSE;
6451 }
6452 return D_O_K;
6453 }
6454
6455 int32_t onLoadReplay()
6456 {
6457 return handle_on_load_replay(ReplayMode::Replay);
6458 }
6459
6460 int32_t onLoadReplayAssert()
6461 {
6462 return handle_on_load_replay(ReplayMode::Assert);
6463 }
6464
6465 int32_t onLoadReplayUpdate()
6466 {
6467 return handle_on_load_replay(ReplayMode::Update);
6468 }
6469
6470 int32_t onSaveReplay()
6471 {
6472 if (replay_get_mode() == ReplayMode::Record)
6473 {
6474 if (!replay_get_meta_bool("test_mode"))
6475 {
6476 if (jwin_alert("Save Replay",
6477 "This will save a copy of the replay up to this point.",
6478 "The official replay file will be untouched.",
6479 "Do you wish to continue?",
6480 "Yes","No",13,27,lfont) != 1)
6481 return D_CLOSE;
6482
6483 char replay_path[2048];
6484 strcpy(replay_path, replay_get_replay_path().string().c_str());
6485 if (jwin_file_select_ex(
6486 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6487 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6488 return D_CLOSE;
6489
6490 if (fileexists(replay_path))
6491 {
6492 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6493 NULL,NULL,"OK",NULL,13,27,lfont);
6494 return D_CLOSE;
6495 }
6496
6497 replay_save(replay_path);
6498 }
6499 else
6500 {
6501 replay_save();
6502 }
6503 }
6504 return D_O_K;
6505 }
6506
6507 static MENU replay_menu[] =
6508 {
6509 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6510 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6511 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6512 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6513 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6514 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6515 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6516
6517 { NULL, NULL, NULL, 0, NULL }
6518 };
6519
6520 static DIALOG credits_dlg[] =
6521 {
6522 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6523 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6524 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6525 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6526 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6527 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6528 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6529 };
6530
6531 24 static ListData dmap_list(dmaplist, &font);
6532
6533 static DIALOG goto_dlg[] =
6534 {
6535 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6536 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6537 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6538 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6539 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6540 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6541 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6542 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6543 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6544 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6545 };
6546
6547 int32_t onGoTo()
6548 {
6549 bool music = false;
6550 music = music;
6551 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6552
6553 goto_dlg[0].dp2=lfont;
6554 goto_dlg[4].d2=cheat_goto_dmap;
6555 goto_dlg[6].dp=cheat_goto_screen_str;
6556
6557 clear_keybuf();
6558
6559 if(is_large)
6560 large_dialog(goto_dlg);
6561
6562 if(zc_popup_dialog(goto_dlg,4)==1)
6563 {
6564 // dmap, screen
6565 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6566 };
6567
6568 return D_O_K;
6569 }
6570
6571 int32_t onGoToComplete()
6572 {
6573 if(!Playing)
6574 {
6575 return D_O_K;
6576 }
6577
6578 system_pal();
6579 music_pause();
6580 pause_all_sfx();
6581 show_mouse(screen);
6582 onGoTo();
6583 eat_buttons();
6584
6585 zc_readrawkey(KEY_ESC);
6586
6587 show_mouse(NULL);
6588 game_pal();
6589 music_resume();
6590 resume_all_sfx();
6591 return D_O_K;
6592 }
6593
6594 int32_t onCredits()
6595 {
6596 go();
6597
6598 BITMAP *win = create_bitmap_ex(8,222,110);
6599
6600 if(!win)
6601 return D_O_K;
6602
6603 int32_t c=0;
6604 int32_t l=0;
6605 int32_t ol=-1;
6606 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6607 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6608 PALETTE tmppal;
6609
6610 rti_gui.transparency_index = 1;
6611
6612 clear_to_color(win, rti_gui.transparency_index);
6613 draw_rle_sprite(win,rle,0,0);
6614 credits_dlg[0].dp2=lfont;
6615 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6616 credits_dlg[2].dp = win;
6617
6618 set_palette_range(black_palette,0,127,false);
6619
6620 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6621
6622 BITMAP* old_screen = screen;
6623 BITMAP* gui_bmp = zc_get_gui_bmp();
6624 ASSERT(gui_bmp);
6625 clear_to_color(gui_bmp, rti_gui.transparency_index);
6626 screen = gui_bmp;
6627
6628 while(update_dialog(p))
6629 {
6630 throttleFPS();
6631 ++c;
6632 l = zc_max((c>>1)-30,0);
6633
6634 if(l > rle->h)
6635 l = c = 0;
6636
6637 if(l > rle->h - 112)
6638 l = rle->h - 112;
6639
6640 clear_bitmap(win);
6641 draw_rle_sprite(win,rle,0,0-l);
6642
6643 if(c<=64)
6644 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6645
6646 set_palette_range(tmppal,0,127,false);
6647
6648 if(l!=ol)
6649 {
6650 scare_mouse();
6651 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6652 unscare_mouse();
6653 SCRFIX();
6654 ol=l;
6655 }
6656
6657 update_hw_screen();
6658 }
6659
6660 screen = old_screen;
6661 system_pal();
6662
6663 shutdown_dialog(p);
6664 destroy_bitmap(win);
6665 //comeback();
6666
6667 rti_gui.transparency_index = 0;
6668
6669 return D_O_K;
6670 }
6671
6672 const char *midilist(int32_t index, int32_t *list_size)
6673 {
6674 if(index<0)
6675 {
6676 *list_size=0;
6677
6678 for(int32_t i=0; i<MAXMIDIS; i++)
6679 if(tunes[i].data)
6680 ++(*list_size);
6681
6682 return NULL;
6683 }
6684
6685 int32_t i=0,m=0;
6686
6687 while(m<=index && i<=MAXMIDIS)
6688 {
6689 if(tunes[i].data)
6690 ++m;
6691
6692 ++i;
6693 }
6694
6695 --i;
6696
6697 if(i==MAXMIDIS && m<index)
6698 return "(null)";
6699
6700 return tunes[i].title;
6701 }
6702
6703 /* ------- MIDI info stuff -------- */
6704
6705 char *text;
6706 midi_info *zmi;
6707 bool dialog_running;
6708 bool listening;
6709
6710 void get_info(int32_t index);
6711
6712 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6713 {
6714 int32_t d2 = d->d2;
6715 int32_t ret = jwin_droplist_proc(msg,d,c);
6716
6717 if(d2!=d->d2)
6718 {
6719 get_info(d->d2);
6720 }
6721
6722 return ret;
6723 }
6724
6725 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6726 {
6727 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6728
6729 int32_t ret = jwin_button_proc(msg,d,c);
6730
6731 if(ret == D_CLOSE)
6732 {
6733 // get current midi index
6734 int32_t index = (d+(d->d1))->d2;
6735 int32_t i=0, m=0;
6736
6737 while(m<=index && i<=MAXMIDIS)
6738 {
6739 if(tunes[i].data)
6740 ++m;
6741
6742 ++i;
6743 }
6744
6745 --i;
6746 jukebox(i);
6747 listening = true;
6748 ret = D_O_K;
6749 }
6750
6751 return ret;
6752 }
6753
6754 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6755 {
6756 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6757
6758 int32_t ret = jwin_button_proc(msg,d,c);
6759
6760 if(ret == D_CLOSE)
6761 {
6762 // get current midi index
6763 int32_t index = (d+(d->d1))->d2;
6764 int32_t i=0, m=0;
6765
6766 while(m<=index && i<=MAXMIDIS)
6767 {
6768 if(tunes[i].data)
6769 ++m;
6770
6771 ++i;
6772 }
6773
6774 --i;
6775
6776 // get file name
6777
6778 int32_t sel=0;
6779 //struct ffblk f;
6780 char title[40] = "Save MIDI: ";
6781 char fname[2048];
6782 memset(fname,0,2048);
6783 static EXT_LIST list[] =
6784 {
6785 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6786 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6787 { NULL, NULL }
6788 };
6789
6790 strcpy(title+11, tunes[i].title);
6791 title[39] = '\0';
6792
6793 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6794 goto done;
6795
6796 if(exists(fname))
6797 {
6798 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6799 goto done;
6800 }
6801
6802 // save midi i
6803
6804 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6805 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6806
6807 done:
6808 chop_path(fname);
6809 ret = D_REDRAW;
6810 }
6811
6812 return ret;
6813 }
6814
6815 24 static ListData midi_list(midilist, &font);
6816
6817 static DIALOG midi_dlg[] =
6818 {
6819 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6820 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6821 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6822 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6823 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6824 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6825 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6826 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6827 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6828 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6829 };
6830
6831 void get_info(int32_t index)
6832 {
6833 int32_t i=0, m=0;
6834
6835 while(m<=index && i<=MAXMIDIS)
6836 {
6837 if(tunes[i].data)
6838 ++m;
6839
6840 ++i;
6841 }
6842
6843 --i;
6844
6845 if(i==MAXMIDIS && m<index)
6846 strcpy(text,"(null)");
6847 else
6848 {
6849 get_midi_info((MIDI*)tunes[i].data,zmi);
6850 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6851 }
6852
6853 midi_dlg[0].dp2=lfont;
6854 midi_dlg[3].dp = text;
6855 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6856 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6857
6858 if(dialog_running)
6859 {
6860 scare_mouse();
6861 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6862 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6863 unscare_mouse();
6864 }
6865 }
6866
6867 int32_t onMIDICredits()
6868 {
6869 text = (char*)malloc(4096);
6870 zmi = (midi_info*)malloc(sizeof(midi_info));
6871
6872 if(!text || !zmi)
6873 {
6874 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6875 return D_O_K;
6876 }
6877
6878 bool do_pause_midi = midi_pos >= 0 && currmidi;
6879 auto restore_midi = currmidi;
6880 if(do_pause_midi)
6881 {
6882 paused_midi_pos = midi_pos;
6883 stop_midi();
6884 midi_paused=true;
6885 midi_suspended = midissuspHALTED;
6886 }
6887
6888 midi_dlg[0].dp2=lfont;
6889 midi_dlg[2].d1 = 0;
6890 midi_dlg[2].d2 = 0;
6891 midi_dlg[4].flags = D_EXIT;
6892 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6893
6894 listening = false;
6895 dialog_running=false;
6896 get_info(0);
6897
6898 dialog_running=true;
6899
6900 if(is_large)
6901 large_dialog(midi_dlg);
6902
6903 zc_popup_dialog(midi_dlg,0);
6904 dialog_running=false;
6905
6906 if(listening)
6907 music_stop();
6908
6909 if(do_pause_midi)
6910 {
6911 midi_suspended = midissuspRESUME;
6912 currmidi = restore_midi;
6913 midi_pos = paused_midi_pos;
6914 }
6915
6916 if(text) free(text);
6917 if(zmi) free(zmi);
6918 return D_O_K;
6919 }
6920
6921 int32_t onAbout()
6922 {
6923 char buf1[80]={0};
6924 std::ostringstream oss;
6925 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6926 oss << buf1 << '\n';
6927 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6928 oss << buf1 << '\n';
6929 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6930 oss << buf1 << '\n';
6931 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6932 oss << buf1 << '\n';
6933 sprintf(buf1, "Tag: %s", getReleaseTag());
6934 oss << buf1 << '\n';
6935
6936 InfoDialog("About ZC", oss.str()).show();
6937 return D_O_K;
6938 }
6939
6940 int32_t onQuest()
6941 {
6942 char fname[100];
6943 strcpy(fname, get_filename(qstpath));
6944 quest_dlg[0].dp2=lfont;
6945 quest_dlg[1].dp = fname;
6946
6947 if(QHeader.quest_number==0)
6948 sprintf(str_a,"Custom");
6949 else
6950 sprintf(str_a,"%d",QHeader.quest_number);
6951
6952 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6953
6954 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6955 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6956
6957 if(is_large)
6958 large_dialog(quest_dlg);
6959
6960 zc_popup_dialog(quest_dlg, 0);
6961 return D_O_K;
6962 }
6963
6964 void call_vidmode_dlg();
6965 int32_t onVidMode()
6966 {
6967 call_vidmode_dlg();
6968 return D_O_K;
6969 }
6970
6971 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6972 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6973 //Added an extra statement, so that if the key is cleared to 0, the cleared
6974 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6975
6976 void load_ukeys(int32_t* arr)
6977 {
6978 arr[ukey_a] = Akey;
6979 arr[ukey_b] = Bkey;
6980 arr[ukey_s] = Skey;
6981 arr[ukey_l] = Lkey;
6982 arr[ukey_r] = Rkey;
6983 arr[ukey_p] = Pkey;
6984 arr[ukey_ex1] = Exkey1;
6985 arr[ukey_ex2] = Exkey2;
6986 arr[ukey_ex3] = Exkey3;
6987 arr[ukey_ex4] = Exkey4;
6988 arr[ukey_du] = DUkey;
6989 arr[ukey_dd] = DDkey;
6990 arr[ukey_dl] = DLkey;
6991 arr[ukey_dr] = DRkey;
6992 arr[ukey_mod1a] = cheat_modifier_keys[0];
6993 arr[ukey_mod1b] = cheat_modifier_keys[1];
6994 arr[ukey_mod2a] = cheat_modifier_keys[2];
6995 arr[ukey_mod2b] = cheat_modifier_keys[3];
6996 };
6997
6998 static const char* ukey_names[] = {
6999 "A", "B", "Start", "L", "R", "Map",
7000 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7001 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7002 "Cheat Mod R1", "Cheat Mod R2",
7003 };
7004 std::string get_ukey_name(int32_t k)
7005 {
7006 if (k < num_ukey) return ukey_names[k];
7007 return "";
7008 }
7009
7010 int32_t onKeyboard()
7011 {
7012 int32_t a = Akey;
7013 int32_t b = Bkey;
7014 int32_t s = Skey;
7015 int32_t l = Lkey;
7016 int32_t r = Rkey;
7017 int32_t p = Pkey;
7018 int32_t ex1 = Exkey1;
7019 int32_t ex2 = Exkey2;
7020 int32_t ex3 = Exkey3;
7021 int32_t ex4 = Exkey4;
7022 int32_t du = DUkey;
7023 int32_t dd = DDkey;
7024 int32_t dl = DLkey;
7025 int32_t dr = DRkey;
7026 int32_t mod1a = cheat_modifier_keys[0];
7027 int32_t mod1b = cheat_modifier_keys[1];
7028 int32_t mod2a = cheat_modifier_keys[2];
7029 int32_t mod2b = cheat_modifier_keys[3];
7030 bool done=false;
7031 int32_t ret;
7032
7033 keyboard_control_dlg[0].dp2=lfont;
7034
7035 if(is_large)
7036 large_dialog(keyboard_control_dlg);
7037
7038 while(!done)
7039 {
7040 ret = zc_popup_dialog(keyboard_control_dlg,3);
7041
7042 if(ret==3) // OK
7043 {
7044 int32_t ukeys[num_ukey];
7045 load_ukeys(ukeys);
7046 std::vector<std::string> uniqueError;
7047 for(int32_t q = 0; q < num_ukey; ++q)
7048 {
7049 for(int32_t p = q+1; p < num_ukey; ++p)
7050 {
7051 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7052 {
7053 char buf[64];
7054 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7055 std::string str(buf);
7056 uniqueError.push_back(str);
7057 }
7058 }
7059 }
7060 if(uniqueError.size() == 0)
7061 {
7062 done = true;
7063 save_control_configs(true);
7064 }
7065 else
7066 {
7067 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7068 box_out("Cannot have duplicate keybinds!"); box_eol();
7069 for(std::vector<std::string>::iterator it = uniqueError.begin();
7070 it != uniqueError.end(); ++it)
7071 {
7072 box_out((*it).c_str()); box_eol();
7073 }
7074 box_end(true);
7075 }
7076 /* Old uniqueness check
7077 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7078 bool unique = true;
7079 addToHash(A,unique,keyhash);
7080 addToHash(B,unique,keyhash);
7081 addToHash(S,unique,keyhash);
7082 addToHash(L,unique,keyhash);
7083 addToHash(R,unique,keyhash);
7084 addToHash(P,unique,keyhash);
7085 addToHash(DU,unique,keyhash);
7086 addToHash(DD,unique,keyhash);
7087 addToHash(DL,unique,keyhash);
7088 addToHash(DR,unique,keyhash);
7089
7090 if(keyhash->find(Exkey1) == keyhash->end())
7091 {
7092 (*keyhash)[Exkey1]=true;
7093 }
7094 else
7095 {
7096 if ( Exkey1 != 0 ) unique = false;
7097 }
7098
7099 if(keyhash->find(Exkey2) == keyhash->end())
7100 {
7101 (*keyhash)[Exkey2]=true;
7102 }
7103 else
7104 {
7105 if ( Exkey2 != 0 ) unique = false;
7106 }
7107
7108 if(keyhash->find(Exkey3) == keyhash->end())
7109 {
7110 (*keyhash)[Exkey3]=true;
7111 }
7112 else
7113 {
7114 if ( Exkey3 != 0 ) unique = false;
7115 }
7116
7117 if(keyhash->find(Exkey4) == keyhash->end())
7118 {
7119 (*keyhash)[Exkey4]=true;
7120 }
7121 else
7122 {
7123 if ( Exkey4 != 0 )unique = false;
7124 }
7125 //modifier keys
7126 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7127 {
7128 (*keyhash)[cheat_modifier_keys[0]]=true;
7129 }
7130 else
7131 {
7132 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7133 }
7134 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7135 {
7136 (*keyhash)[cheat_modifier_keys[1]]=true;
7137 }
7138 else
7139 {
7140 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7141 }
7142 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7143 {
7144 (*keyhash)[cheat_modifier_keys[2]]=true;
7145 }
7146 else
7147 {
7148 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7149 }
7150 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7151 {
7152 (*keyhash)[cheat_modifier_keys[3]]=true;
7153 }
7154 else
7155 {
7156 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7157 }
7158
7159 delete keyhash;
7160
7161 if(unique)
7162 done=true;
7163 else
7164 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7165 */
7166 }
7167 else // Cancel
7168 {
7169 Akey = a;
7170 Bkey = b;
7171 Skey = s;
7172 Lkey = l;
7173 Rkey = r;
7174 Pkey = p;
7175 Exkey1 = ex1;
7176 Exkey2 = ex2;
7177 Exkey3 = ex3;
7178 Exkey4 = ex4;
7179 DUkey = du;
7180 DDkey = dd;
7181 DLkey = dl;
7182 DRkey = dr;
7183 cheat_modifier_keys[0] = mod1a;
7184 cheat_modifier_keys[1] = mod1b;
7185 cheat_modifier_keys[2] = mod2a;
7186 cheat_modifier_keys[3] = mod2b;
7187
7188 done=true;
7189 }
7190
7191 rest(1);
7192 }
7193
7194 return D_O_K;
7195 }
7196
7197 int32_t onGamepad()
7198 {
7199 int32_t a = Abtn;
7200 int32_t b = Bbtn;
7201 int32_t s = Sbtn;
7202 int32_t l = Lbtn;
7203 int32_t r = Rbtn;
7204 int32_t m = Mbtn;
7205 int32_t p = Pbtn;
7206 int32_t ex1 = Exbtn1;
7207 int32_t ex2 = Exbtn2;
7208 int32_t ex3 = Exbtn3;
7209 int32_t ex4 = Exbtn4;
7210 int32_t up = DUbtn;
7211 int32_t down = DDbtn;
7212 int32_t left = DLbtn;
7213 int32_t right = DRbtn;
7214
7215 gamepad_dlg[0].dp2=lfont;
7216 if(analog_movement)
7217 gamepad_dlg[56].flags|=D_SELECTED;
7218 else
7219 gamepad_dlg[56].flags&=~D_SELECTED;
7220
7221 if(is_large)
7222 large_dialog(gamepad_dlg);
7223
7224 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7225
7226 if(ret == 4) //OK
7227 {
7228 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7229 save_control_configs(false);
7230 }
7231 else //Cancel
7232 {
7233 Abtn = a;
7234 Bbtn = b;
7235 Sbtn = s;
7236 Lbtn = l;
7237 Rbtn = r;
7238 Mbtn = m;
7239 Pbtn = p;
7240 Exbtn1 = ex1;
7241 Exbtn2 = ex2;
7242 Exbtn3 = ex3;
7243 Exbtn4 = ex4;
7244 DUbtn = up;
7245 DDbtn = down;
7246 DLbtn = left;
7247 DRbtn = right;
7248 }
7249
7250 return D_O_K;
7251 }
7252
7253 int32_t onSound()
7254 {
7255 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7256 {
7257 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7258 }
7259 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7260 {
7261 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7262 }
7263 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7264 {
7265 emusic_volume = (int32_t)FFCore.usr_music_volume;
7266 }
7267 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7268 {
7269 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7270 }
7271 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7272 {
7273 pan_style = (int32_t)FFCore.usr_panstyle;
7274 }
7275
7276 int32_t m = midi_volume;
7277 int32_t d = digi_volume;
7278 int32_t e = emusic_volume;
7279 int32_t b = zcmusic_bufsz;
7280 int32_t s = sfx_volume;
7281 int32_t p = pan_style;
7282 pan_style = vbound(pan_style,0,3);
7283
7284 sound_dlg[0].dp2=lfont;
7285
7286 if(is_large)
7287 large_dialog(sound_dlg);
7288
7289 midi_dp[1] = sound_dlg[6].x;
7290 midi_dp[2] = sound_dlg[6].y;
7291 digi_dp[1] = sound_dlg[7].x;
7292 digi_dp[2] = sound_dlg[7].y;
7293 emus_dp[1] = sound_dlg[8].x;
7294 emus_dp[2] = sound_dlg[8].y;
7295 buf_dp[1] = sound_dlg[9].x;
7296 buf_dp[2] = sound_dlg[9].y;
7297 sfx_dp[1] = sound_dlg[10].x;
7298 sfx_dp[2] = sound_dlg[10].y;
7299 pan_dp[1] = sound_dlg[11].x;
7300 pan_dp[2] = sound_dlg[11].y;
7301 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7302 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7303 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7304 sound_dlg[18].d2 = zcmusic_bufsz;
7305 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7306 sound_dlg[20].d2 = pan_style;
7307
7308 int32_t ret = zc_popup_dialog(sound_dlg,1);
7309
7310 if(ret==2)
7311 {
7312 master_volume(digi_volume,midi_volume);
7313
7314 for(int32_t i=0; i<WAV_COUNT; ++i)
7315 {
7316 //allegro assertion fails when passing in -1 as voice -DD
7317 if(sfx_voice[i] > 0)
7318 voice_set_volume(sfx_voice[i], sfx_volume);
7319 }
7320 zc_set_config(sfx_sect,"digi",digi_volume);
7321 zc_set_config(sfx_sect,"midi",midi_volume);
7322 zc_set_config(sfx_sect,"sfx",sfx_volume);
7323 zc_set_config(sfx_sect,"emusic",emusic_volume);
7324 zc_set_config(sfx_sect,"pan",pan_style);
7325 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7326 }
7327 else
7328 {
7329 midi_volume = m;
7330 digi_volume = d;
7331 emusic_volume = e;
7332 zcmusic_bufsz = b;
7333 sfx_volume = s;
7334 pan_style = p;
7335 }
7336
7337 return D_O_K;
7338 }
7339
7340 int32_t queding(char const* s1, char const* s2, char const* s3)
7341 {
7342 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7343 }
7344
7345 int32_t onQuit()
7346 {
7347 if(Playing)
7348 {
7349 int32_t ret=0;
7350
7351 if(get_bit(quest_rules, qr_NOCONTINUE))
7352 {
7353 if(standalone_mode)
7354 {
7355 ret=queding("End current game?",
7356 "The continue screen is disabled; the game",
7357 "will be reloaded from the last save.");
7358 }
7359 else
7360 {
7361 ret=queding("End current game?",
7362 "The continue screen is disabled. You will",
7363 "be returned to the file select screen.");
7364 }
7365 }
7366 else
7367 ret=queding("End current game?",NULL,NULL);
7368
7369 if(ret==1)
7370 {
7371 disableClickToFreeze=false;
7372 Quit=qQUIT;
7373
7374 // Trying to evade a door repair charge?
7375 if(repaircharge)
7376 {
7377 game->change_drupy(-repaircharge);
7378 repaircharge=0;
7379 }
7380
7381 return D_CLOSE;
7382 }
7383 }
7384
7385 return D_O_K;
7386 }
7387
7388 int32_t onTryQuitMenu()
7389 {
7390 return onTryQuit(true);
7391 }
7392
7393 int32_t onTryQuit(bool inMenu)
7394 {
7395 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7396 {
7397 if(get_bit(quest_rules,qr_OLD_F6))
7398 {
7399 if(inMenu) onQuit();
7400 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7401 }
7402 else
7403 {
7404 disableClickToFreeze=false;
7405 GameFlags |= GAMEFLAG_TRYQUIT;
7406 }
7407 return D_CLOSE;
7408 }
7409
7410 return D_O_K;
7411 }
7412
7413 int32_t onReset()
7414 {
7415 if(queding(" Reset system? ",NULL,NULL)==1)
7416 {
7417 disableClickToFreeze=false;
7418 Quit=qRESET;
7419 replay_quit();
7420 return D_CLOSE;
7421 }
7422
7423 return D_O_K;
7424 }
7425
7426 int32_t onExit()
7427 {
7428 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7429 {
7430 Quit=qEXIT;
7431 return D_CLOSE;
7432 }
7433
7434 return D_O_K;
7435 }
7436
7437 int32_t onTitle_NES()
7438 {
7439 title_version=0;
7440 zc_set_config(cfg_sect,"title",title_version);
7441 return D_O_K;
7442 }
7443 int32_t onTitle_DX()
7444 {
7445 title_version=1;
7446 zc_set_config(cfg_sect,"title",title_version);
7447 return D_O_K;
7448 }
7449 int32_t onTitle_25()
7450 {
7451 title_version=2;
7452 zc_set_config(cfg_sect,"title",title_version);
7453 return D_O_K;
7454 }
7455
7456 int32_t onDebug()
7457 {
7458 if(debug_enabled)
7459 set_debug(!get_debug());
7460 return D_O_K;
7461 }
7462
7463 int32_t onHeartBeep()
7464 {
7465 heart_beep=!heart_beep;
7466 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7467 return D_O_K;
7468 }
7469
7470 int32_t onSaveIndicator()
7471 {
7472 use_save_indicator=!use_save_indicator;
7473 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7474 return D_O_K;
7475 }
7476
7477 int32_t onEpilepsy()
7478 {
7479 if(jwin_alert3(
7480 "Epilepsy Flash Reduction",
7481 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7482 "Disabling this will restore standard flash and wavy behaviour.",
7483 "Proceed?",
7484 "&Yes",
7485 "&No",
7486 NULL,
7487 'y',
7488 'n',
7489 0,
7490 lfont) == 1)
7491 {
7492 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7493 zc_set_config("zeldadx","checked_epilepsy",1);
7494 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7495 }
7496 return D_O_K;
7497 }
7498
7499 int32_t onTriforce()
7500 {
7501 for(int32_t i=0; i<MAXINITTABS; ++i)
7502 {
7503 init_tabs[i].flags&=~D_SELECTED;
7504 }
7505
7506 init_tabs[3].flags=D_SELECTED;
7507 return onCheatConsole();
7508 /*triforce_dlg[0].dp2=lfont;
7509 for(int32_t i=1; i<=8; i++)
7510 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7511
7512 if(zc_popup_dialog (triforce_dlg,-1)==9)
7513 {
7514 for(int32_t i=1; i<=8; i++)
7515 {
7516 game->lvlitems[i] &= ~liTRIFORCE;
7517 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7518 }
7519 }
7520 return D_O_K;*/
7521 }
7522
7523 bool rc = false;
7524 /*
7525 int32_t onEquipment()
7526 {
7527 for (int32_t i=0; i<MAXINITTABS; ++i)
7528 {
7529 init_tabs[i].flags&=~D_SELECTED;
7530 }
7531 init_tabs[0].flags=D_SELECTED;
7532 return onCheatConsole();
7533 }
7534 */
7535
7536 int32_t onItems()
7537 {
7538 for(int32_t i=0; i<MAXINITTABS; ++i)
7539 {
7540 init_tabs[i].flags&=~D_SELECTED;
7541 }
7542
7543 init_tabs[1].flags=D_SELECTED;
7544 return onCheatConsole();
7545 }
7546
7547 static DIALOG getnum_dlg[] =
7548 {
7549 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7550 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7551 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7552 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7553 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7554 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7555 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7556 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7557 };
7558
7559 int32_t getnumber(const char *prompt,int32_t initialval)
7560 {
7561 char buf[20];
7562 sprintf(buf,"%d",initialval);
7563 getnum_dlg[0].dp=(void *)prompt;
7564 getnum_dlg[0].dp2=lfont;
7565 getnum_dlg[2].dp=buf;
7566
7567 if(is_large)
7568 large_dialog(getnum_dlg);
7569
7570 if(zc_popup_dialog(getnum_dlg,2)==3)
7571 return atoi(buf);
7572
7573 return initialval;
7574 }
7575
7576 int32_t onLife()
7577 {
7578 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7579 cheats_enqueue(Cheat::Life, value);
7580 return D_O_K;
7581 }
7582
7583 int32_t onHeartC()
7584 {
7585 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7586 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7587 cheats_enqueue(Cheat::MaxLife, max_life);
7588 cheats_enqueue(Cheat::Life, life);
7589 return D_O_K;
7590 }
7591
7592 int32_t onMagicC()
7593 {
7594 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7595 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7596 cheats_enqueue(Cheat::MaxMagic, max_magic);
7597 cheats_enqueue(Cheat::Magic, magic);
7598 return D_O_K;
7599 }
7600
7601 int32_t onRupies()
7602 {
7603 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7604 cheats_enqueue(Cheat::Rupies, value);
7605 return D_O_K;
7606 }
7607
7608 int32_t onMaxBombs()
7609 {
7610 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7611 cheats_enqueue(Cheat::MaxBombs, value);
7612 cheats_enqueue(Cheat::Bombs, value);
7613 return D_O_K;
7614 }
7615
7616 int32_t onRefillLife()
7617 {
7618 cheats_enqueue(Cheat::Life, game->get_maxlife());
7619 return D_O_K;
7620 }
7621 int32_t onRefillMagic()
7622 {
7623 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7624 return D_O_K;
7625 }
7626 int32_t onClock()
7627 {
7628 cheats_enqueue(Cheat::Clock);
7629 return D_O_K;
7630 }
7631
7632 int32_t onQstPath()
7633 {
7634 char path[2048];
7635
7636 chop_path(qstdir);
7637 strcpy(path,qstdir);
7638
7639 go();
7640
7641 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7642 {
7643 chop_path(path);
7644 fix_filename_case(path);
7645 fix_filename_slashes(path);
7646 strcpy(qstdir,path);
7647 strcpy(qstpath,qstdir);
7648 }
7649
7650 comeback();
7651 return D_O_K;
7652 }
7653
7654 #include "dialog/cheat_dialog.h"
7655 int32_t onCheat()
7656 {
7657 call_setcheat_dialog();
7658 game->set_cheat(maxcheat);
7659 if(cheat) game->did_cheat(true);
7660 return D_O_K;
7661 }
7662
7663 int32_t onCheatRupies()
7664 {
7665 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7666 return D_O_K;
7667 }
7668
7669 int32_t onCheatArrows()
7670 {
7671 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7672 return D_O_K;
7673 }
7674
7675 int32_t onCheatBombs()
7676 {
7677 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7678 return D_O_K;
7679 }
7680
7681 // *** screen saver
7682
7683 4391436 int32_t after_time()
7684 {
7685
1/2
✓ Branch 0 taken 4391436 times.
✗ Branch 1 not taken.
4391436 if(ss_enable == 0)
7686 return INT_MAX;
7687
7688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4391436 times.
4391436 if(ss_after <= 0)
7689 return 5 * 60;
7690
7691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4391436 times.
4391436 if(ss_after <= 3)
7692 return ss_after * 15 * 60;
7693
7694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4391436 times.
4391436 if(ss_after <= 13)
7695 return (ss_after - 3) * 60 * 60;
7696
7697 4391436 return MAX_IDLE + 1;
7698 4391436 }
7699
7700 static const char *after_str[15] =
7701 {
7702 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7703 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7704 "Never"
7705 };
7706
7707 const char *after_list(int32_t index, int32_t *list_size)
7708 {
7709 if(index < 0)
7710 {
7711 *list_size = 15;
7712 return NULL;
7713 }
7714
7715 return after_str[index];
7716 }
7717
7718 24 static ListData after__list(after_list, &font);
7719
7720 static DIALOG scrsaver_dlg[] =
7721 {
7722 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7723 24 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7724 24 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7725 24 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7726 24 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7727 24 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7728 24 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7729 24 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7730 24 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7731 24 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7732 24 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7733 24 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7734 24 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7735 24 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7736 };
7737
7738 int32_t onScreenSaver()
7739 {
7740 scrsaver_dlg[0].dp2=lfont;
7741 int32_t oldcfgs[3];
7742 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7743 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7744 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7745
7746 if(is_large)
7747 large_dialog(scrsaver_dlg);
7748
7749 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7750
7751 if(ret == 8 || ret == 9)
7752 {
7753 ss_after = scrsaver_dlg[5].d1;
7754 ss_speed = scrsaver_dlg[6].d2;
7755 ss_density = scrsaver_dlg[7].d2;
7756 if(oldcfgs[0] != ss_after)
7757 zc_set_config(cfg_sect,"ss_after",ss_after);
7758 if(oldcfgs[1] != ss_speed)
7759 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7760 if(oldcfgs[2] != ss_density)
7761 zc_set_config(cfg_sect,"ss_density",ss_density);
7762 }
7763
7764 if(ret == 9)
7765 // preview Screen Saver
7766 {
7767 clear_keybuf();
7768 scare_mouse();
7769 Matrix(ss_speed, ss_density, 30);
7770 system_pal();
7771 unscare_mouse();
7772 }
7773
7774 return D_O_K;
7775 }
7776
7777 /***** Menus *****/
7778
7779 static MENU game_menu[] =
7780 {
7781 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7782 { (char *)"", NULL, NULL, 0, NULL },
7783 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7784 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7785 { (char *)"", NULL, NULL, 0, NULL },
7786 #ifdef __EMSCRIPTEN__
7787 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7788 #elif defined(ALLEGRO_MACOSX)
7789 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7790 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7791 #else
7792 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7793 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7794 #endif
7795 { NULL, NULL, NULL, 0, NULL }
7796 };
7797
7798 static MENU title_menu[] =
7799 {
7800 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7801 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7802 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7803 { NULL, NULL, NULL, 0, NULL }
7804 };
7805
7806 static MENU snapshot_format_menu[] =
7807 {
7808 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7809 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7810 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7811 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7812 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7813 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7814 { NULL, NULL, NULL, 0, NULL }
7815 };
7816
7817 static MENU controls_menu[] =
7818 {
7819 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7820 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7821 { NULL, NULL, NULL, 0, NULL }
7822 };
7823
7824 static MENU name_entry_mode_menu[] =
7825 {
7826 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7827 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7828 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7829 { NULL, NULL, NULL, 0, NULL }
7830 };
7831
7832 static void set_controls_menu_active()
7833 {
7834
7835 }
7836
7837 static MENU settings_menu[] =
7838 {
7839 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7840 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7841 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7842 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7843 { (char *)"", NULL, NULL, 0, NULL },
7844 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7845 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7846 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7847 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7848 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7849 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7850 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7851 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7852 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7853 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7854 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7855 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7856 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7857 { (char *)"", NULL, NULL, 0, NULL },
7858 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7859 { (char *)"", NULL, NULL, 0, NULL },
7860 { NULL, NULL, NULL, 0, NULL }
7861 };
7862
7863
7864 static MENU misc_menu[] =
7865 {
7866 { (char *)"&About...", onAbout, NULL, 0, NULL },
7867 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7868 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7869 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7870 { (char *)"", NULL, NULL, 0, NULL },
7871 //5
7872 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7873 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7874 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7875 { (char *)"", NULL, NULL, 0, NULL },
7876 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7877 //10
7878 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7879 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7880 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7881 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7882 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7883 //15
7884 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7885 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7886 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7887
7888 { NULL, NULL, NULL, 0, NULL }
7889 };
7890
7891 static MENU refill_menu[] =
7892 {
7893 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7894 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7895 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7896 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7897 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7898 { NULL, NULL, NULL, 0, NULL }
7899 };
7900
7901 static MENU show_menu[] =
7902 {
7903 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7904 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7905 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7906 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7907 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7908 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7909 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7910 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7911 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7912 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7913 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7914 { (char *)"", NULL, NULL, 0, NULL },
7915 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7916 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7917 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7918 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7919 { NULL, NULL, NULL, 0, NULL }
7920 };
7921
7922 static MENU cheat_menu[] =
7923 {
7924 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7925 { (char *)"", NULL, NULL, 0, NULL },
7926 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7927 { (char *)"", NULL, NULL, 0, NULL },
7928 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7929 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7930 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7931 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7932 { (char *)"", NULL, NULL, 0, NULL },
7933 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7934 { (char *)"", NULL, NULL, 0, NULL },
7935 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7936 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7937 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7938 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7939 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7940 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7941 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7942 { NULL, NULL, NULL, 0, NULL }
7943 };
7944
7945 static MENU fixes_menu[] =
7946 {
7947 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7948 { NULL, NULL, NULL, 0, NULL }
7949 };
7950
7951 #if DEVLEVEL > 0
7952 int32_t devLogging();
7953 int32_t devDebug();
7954 int32_t devTimestmp();
7955 #if DEVLEVEL > 1
7956 int32_t setCheat();
7957 #endif //DEVLEVEL > 1
7958 enum
7959 {
7960 dv_log,
7961 // dv_dbg,
7962 dv_tmpstmp,
7963 #if DEVLEVEL > 1
7964 dv_nil,
7965 dv_setcheat,
7966 #endif //DEVLEVEL > 1
7967 dv_max
7968 };
7969 static MENU dev_menu[] =
7970 {
7971 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7972 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7973 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7974 #if DEVLEVEL > 1
7975 { (char *)"", NULL, NULL, 0, NULL },
7976 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7977 #endif //DEVLEVEL > 1
7978 { NULL, NULL, NULL, 0, NULL }
7979 };
7980 int32_t devLogging()
7981 {
7982 dev_logging = !dev_logging;
7983 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7984 return D_O_K;
7985 }
7986 // int32_t devDebug()
7987 // {
7988 // dev_debug = !dev_debug;
7989 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7990 // return D_O_K;
7991 // }
7992 int32_t devTimestmp()
7993 {
7994 dev_timestmp = !dev_timestmp;
7995 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7996 return D_O_K;
7997 }
7998 #if DEVLEVEL > 1
7999 int32_t setCheat()
8000 {
8001 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8002 return D_O_K;
8003 }
8004 #endif //DEVLEVEL > 1
8005 #endif //DEVLEVEL > 0
8006
8007 MENU the_player_menu[] =
8008 {
8009 { (char *)"&Game", NULL, game_menu, 0, NULL },
8010 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8011 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8012 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8013 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8014 #if DEVLEVEL > 0
8015 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8016 #endif
8017 { NULL, NULL, NULL, 0, NULL }
8018 };
8019
8020 MENU the_player_menu2[] =
8021 {
8022 { (char *)"&Game", NULL, game_menu, 0, NULL },
8023 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8024 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8025 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8026 #if DEVLEVEL > 0
8027 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8028 #endif
8029 { NULL, NULL, NULL, 0, NULL }
8030 };
8031
8032 int32_t onMIDIPatch()
8033 {
8034 if(jwin_alert3(
8035 "Toggle Windows MIDI Fix",
8036 "This action will change whether ZC Player auto-restarts a MIDI at its",
8037 "last index if you move ZC Player out of focus, then back into focus.",
8038 "Proceed?",
8039 "&Yes",
8040 "&No",
8041 NULL,
8042 'y',
8043 'n',
8044 0,
8045 lfont) == 1)
8046 {
8047 midi_patch_fix = midi_patch_fix ? 0 : 1;
8048 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8049 }
8050 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8051 return D_O_K;
8052 }
8053
8054 int32_t onKeyboardEntry()
8055 {
8056 NameEntryMode=0;
8057 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8058 return D_O_K;
8059 }
8060
8061 int32_t onLetterGridEntry()
8062 {
8063 NameEntryMode=1;
8064 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8065 return D_O_K;
8066 }
8067
8068 int32_t onExtLetterGridEntry()
8069 {
8070 NameEntryMode=2;
8071 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8072 return D_O_K;
8073 }
8074
8075 static BITMAP* oldscreen;
8076 int32_t onFullscreenMenu()
8077 {
8078 // super hacks
8079 screen = oldscreen;
8080 if (onFullscreen() == D_REDRAW)
8081 {
8082 oldscreen = screen;
8083 }
8084 screen = menu_bmp;
8085 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8086 return D_O_K;
8087 }
8088
8089 24 void fix_menu()
8090 {
8091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!debug_enabled)
8092 24 settings_menu[18].text = NULL;
8093 24 }
8094
8095 static DIALOG system_dlg[] =
8096 {
8097 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8098 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8099 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8100 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8101 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8102 #ifndef ALLEGRO_MACOSX
8103 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8104 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8105 #else
8106 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8107 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8108 #endif
8109 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8110 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8111 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8112 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8113 };
8114
8115 static DIALOG system_dlg2[] =
8116 {
8117 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8118 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8119 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8120 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8121 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8122 #ifndef ALLEGRO_MACOSX
8123 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8124 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8125 #else
8126 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8127 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8128 #endif
8129 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8130 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8131 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8132 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8133 };
8134
8135 void reset_snapshot_format_menu()
8136 {
8137 for(int32_t i=0; i<ssfmtMAX; ++i)
8138 {
8139 snapshot_format_menu[i].flags=0;
8140 }
8141 }
8142
8143 int32_t onSetSnapshotFormat()
8144 {
8145 switch(active_menu->text[1])
8146 {
8147 case 'B': //"&BMP"
8148 SnapshotFormat=0;
8149 break;
8150
8151 case 'G': //"&GIF"
8152 SnapshotFormat=1;
8153 break;
8154
8155 case 'J': //"&JPG"
8156 SnapshotFormat=2;
8157 break;
8158
8159 case 'P': //"&PNG"
8160 SnapshotFormat=3;
8161 break;
8162
8163 case 'C': //"PC&X"
8164 SnapshotFormat=4;
8165 break;
8166
8167 case 'T': //"&TGA"
8168 SnapshotFormat=5;
8169 break;
8170
8171 case 'L': //"&LBM"
8172 SnapshotFormat=6;
8173 break;
8174 }
8175 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8176
8177 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8178 return D_O_K;
8179 }
8180
8181
8182 38 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8183 {
8184 PALETTE tmp;
8185
8186
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(int32_t i=0; i<256; i++)
8187 {
8188 9728 tmp[i].r=r;
8189 9728 tmp[i].g=g;
8190 9728 tmp[i].b=b;
8191 9728 }
8192
8193 38 fade_interpolate(src,tmp,dest,pos,from,to);
8194 38 }
8195
8196 38 void system_pal()
8197 {
8198 38 is_sys_pal = true;
8199 static PALETTE pal;
8200 38 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8201
8202 // set up the grayscale palette
8203
2/2
✓ Branch 0 taken 2432 times.
✓ Branch 1 taken 38 times.
2470 for(int32_t i=128; i<192; i++)
8204 {
8205 2432 pal[i].r = i-128;
8206 2432 pal[i].g = i-128;
8207 2432 pal[i].b = i-128;
8208 2432 }
8209 38 load_colorset(gui_colorset, pal);
8210
8211 38 color_layer(pal, pal, 24,16,16, 28, 128,191);
8212
8213
2/2
✓ Branch 0 taken 4864 times.
✓ Branch 1 taken 38 times.
4902 for(int32_t i=0; i<256; i+=2)
8214 {
8215 4864 int32_t v = (i>>3)+2;
8216 4864 int32_t c = (i>>3)+192;
8217 4864 pal[c] = _RGB(v,v,v+(v>>1));
8218 /*
8219 if(i<240)
8220 {
8221 _allegro_hline(tmp_scr,0,i,319,c);
8222 _allegro_hline(tmp_scr,0,i+1,319,c);
8223 }
8224 */
8225 4864 }
8226
8227 // draw the vertical screen gradient
8228
2/2
✓ Branch 0 taken 9120 times.
✓ Branch 1 taken 38 times.
9158 for(int32_t i=0; i<240; ++i)
8229 {
8230 9120 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8231 9120 }
8232
8233 /*
8234 palrstart= 10*63/255; palrend=166*63/255;
8235 palgstart= 36*63/255; palgend=202*63/255;
8236 palbstart=106*63/255; palbend=240*63/255;
8237 paldivs=32;
8238 for(int32_t i=0; i<paldivs; i++)
8239 {
8240 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8241 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8242 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8243 }
8244 */
8245 38 BITMAP *panorama = create_bitmap_ex(8,256,224);
8246 int32_t ts_height, ts_start;
8247
8248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8249 {
8250 clear_to_color(panorama,0);
8251 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8252 ts_height=224-passive_subscreen_height;
8253 ts_start=28;
8254 }
8255 else
8256 {
8257 38 blit(framebuf,panorama,0,0,0,0,256,224);
8258 38 ts_height=224;
8259 38 ts_start=0;
8260 }
8261
8262 // gray scale the current frame
8263
2/2
✓ Branch 0 taken 8512 times.
✓ Branch 1 taken 38 times.
8550 for(int32_t y=0; y<ts_height; y++)
8264 {
8265
2/2
✓ Branch 0 taken 2179072 times.
✓ Branch 1 taken 8512 times.
2187584 for(int32_t x=0; x<256; x++)
8266 {
8267 2179072 int32_t c = panorama->line[y+ts_start][x];
8268
2/2
✓ Branch 0 taken 2173182 times.
✓ Branch 1 taken 5890 times.
2179072 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8269 2179072 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8270 2179072 }
8271 8512 }
8272
8273 38 destroy_bitmap(panorama);
8274
8275 // display everything
8276 38 vsync();
8277 38 hw_palette = &pal;
8278 38 update_hw_pal = true;
8279
8280 // sys_pal = pal;
8281 38 memcpy(sys_pal,pal,sizeof(pal));
8282 38 }
8283
8284 void system_pal2()
8285 {
8286 is_sys_pal = true;
8287 static PALETTE RAMpal2;
8288 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8289
8290 /* Windows 2000 colors
8291 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8292 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8293 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8294 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8295 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8296 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8297 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8298 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8299
8300 byte palrstart= 10*63/255, palrend=166*63/255,
8301 palgstart= 36*63/255, palgend=202*63/255,
8302 palbstart=106*63/255, palbend=240*63/255,
8303 paldivs=7;
8304 for(int32_t i=0; i<paldivs; i++)
8305 {
8306 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8307 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8308 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8309 }
8310 */
8311
8312 /* Windows 98 colors
8313 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8314 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8315 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8316 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8317 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8318 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8319 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8320 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8321
8322 byte palrstart= 0*63/255, palrend=166*63/255,
8323 palgstart= 0*63/255, palgend=202*63/255,
8324 palbstart=128*63/255, palbend=240*63/255,
8325 paldivs=7;
8326 for(int32_t i=0; i<paldivs; i++)
8327 {
8328 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8329 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8330 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8331 }
8332 */
8333
8334 /* Windows 99 colors
8335 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8336 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8337 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8338 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8339 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8340 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8341 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8342 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8343 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8344
8345 byte palrstart= 0*63/255, palrend=166*63/255,
8346 palgstart= 0*63/255, palgend=202*63/255,
8347
8348 palbstart=128*63/255, palbend=240*63/255,
8349 paldivs=6;
8350 for(int32_t i=0; i<paldivs; i++)
8351 {
8352 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8353 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8354 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8355 }
8356 */
8357
8358
8359
8360 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8361 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8362 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8363 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8364 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8365 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8366 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8367 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8368 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8369
8370 byte palrstart= 0*63/255, palrend=166*63/255,
8371 palgstart= 0*63/255, palgend=202*63/255,
8372 palbstart=128*63/255, palbend=240*63/255,
8373 paldivs=6;
8374
8375 for(int32_t i=0; i<paldivs; i++)
8376 {
8377 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8378 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8379 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8380 }
8381
8382 gui_bg_color=jwin_pal[jcBOX];
8383 gui_fg_color=jwin_pal[jcBOXFG];
8384
8385 jwin_set_colors(jwin_pal);
8386
8387
8388 // set up the new palette
8389 for(int32_t i=128; i<192; i++)
8390 {
8391 RAMpal2[i].r = i-128;
8392 RAMpal2[i].g = i-128;
8393 RAMpal2[i].b = i-128;
8394 }
8395
8396 /*
8397 for(int32_t i=0; i<64; i++)
8398 {
8399 RAMpal2[128+i] = _RGB(i,i,i)1));
8400 }
8401 */
8402
8403 /*
8404
8405 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8406 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8407 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8408 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8409 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8410 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8411 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8412
8413 gui_fg_color=vc(14);
8414 gui_bg_color=vc(1);
8415
8416 jwin_set_colors(jwin_pal);
8417 */
8418
8419 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8420
8421 // set up the colors for the vertical screen gradient
8422 for(int32_t i=0; i<256; i+=2)
8423 {
8424 int32_t v = (i>>3)+2;
8425 int32_t c = (i>>3)+192;
8426 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8427
8428 /*
8429 if(i<240)
8430 {
8431 _allegro_hline(tmp_scr,0,i,319,c);
8432 _allegro_hline(tmp_scr,0,i+1,319,c);
8433 }
8434 */
8435 }
8436
8437 // hw_palette = &RAMpal;
8438 // update_hw_pal = true;
8439
8440 for(int32_t i=0; i<240; ++i)
8441 {
8442 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8443 }
8444
8445 /*
8446 byte palrstart= 10*63/255, palrend=166*63/255,
8447 palgstart= 36*63/255, palgend=202*63/255,
8448 palbstart=106*63/255, palbend=240*63/255,
8449 paldivs=32;
8450 for(int32_t i=0; i<paldivs; i++)
8451 {
8452 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8453 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8454 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8455 }
8456 */
8457 BITMAP *panorama = create_bitmap_ex(8,256,224);
8458 int32_t ts_height, ts_start;
8459
8460 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8461 {
8462 clear_to_color(panorama,0);
8463 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8464 ts_height=224-passive_subscreen_height;
8465 ts_start=28;
8466 }
8467 else
8468 {
8469 blit(framebuf,panorama,0,0,0,0,256,224);
8470 ts_height=224;
8471 ts_start=0;
8472 }
8473
8474 // gray scale the current frame
8475 for(int32_t y=0; y<ts_height; y++)
8476 {
8477 for(int32_t x=0; x<256; x++)
8478 {
8479 int32_t c = panorama->line[y+ts_start][x];
8480 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8481 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8482 }
8483 }
8484
8485 destroy_bitmap(panorama);
8486
8487 // display everything
8488 vsync();
8489 hw_palette = &RAMpal2;
8490 update_hw_pal = true;
8491
8492 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8493
8494 // sys_pal = pal;
8495 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8496 }
8497
8498 static uint32_t entered_sys_pal = 0;
8499 14 void enter_sys_pal()
8500 {
8501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8502 {
8503 if(entered_sys_pal)
8504 ++entered_sys_pal;
8505 return;
8506 }
8507 14 system_pal();
8508 14 ++entered_sys_pal;
8509 14 }
8510 14 void exit_sys_pal()
8511 {
8512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8513 {
8514
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8515 {
8516 14 game_pal();
8517 14 }
8518 14 }
8519 14 }
8520
8521 void switch_out_callback()
8522 {
8523 if (pause_in_background)
8524 {
8525 callback_switchin = 3;
8526 return;
8527 }
8528
8529 #ifdef _WIN32
8530 if(midi_patch_fix==0 || currmidi==-1)
8531 return;
8532
8533
8534 paused_midi_pos = midi_pos;
8535 zc_stop_midi();
8536 midi_paused=true;
8537 midi_suspended = midissuspHALTED;
8538 #endif
8539 }
8540
8541 void switch_in_callback()
8542 {
8543 if(pause_in_background)
8544 {
8545 return;
8546 }
8547
8548 #ifdef _WIN32
8549 if(midi_patch_fix==0 || currmidi==-1)
8550 return;
8551
8552 else
8553 {
8554 callback_switchin = 1;
8555 midi_suspended = midissuspRESUME;
8556 }
8557 #endif
8558 }
8559
8560 190 void game_pal()
8561 {
8562 190 is_sys_pal = false;
8563 190 entered_sys_pal = 0;
8564 190 clear_to_color(screen,BLACK);
8565 190 hw_palette = &RAMpal;
8566 190 update_hw_pal = true;
8567 190 }
8568
8569 static char bar_str[] = "";
8570
8571 14 void music_pause()
8572 {
8573 //al_pause_duh(tmplayer);
8574 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8575 14 zc_midi_pause();
8576 14 midi_paused=true;
8577 14 }
8578
8579 void music_resume()
8580 {
8581 //al_resume_duh(tmplayer);
8582 zcmusic_pause(zcmusic, ZCM_RESUME);
8583 zc_midi_resume();
8584 midi_paused=false;
8585 }
8586
8587 3654 void music_stop()
8588 {
8589 //al_stop_duh(tmplayer);
8590 //unload_duh(tmusic);
8591 //tmusic=NULL;
8592 //tmplayer=NULL;
8593 3654 zcmusic_stop(zcmusic);
8594 3654 zcmusic_unload_file(zcmusic);
8595 3654 zc_stop_midi();
8596 3654 midi_paused=false;
8597 3654 currmidi=-1;
8598 3654 }
8599
8600 void System()
8601 {
8602 mouse_down=gui_mouse_b();
8603 music_pause();
8604 pause_all_sfx();
8605 MenuOpen = true;
8606 system_pal();
8607 // FONT *oldfont=font;
8608 // font=tfont;
8609
8610 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8611 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8612
8613 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8614 #if DEVLEVEL > 1
8615 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8616 #endif
8617 game_menu[3].flags =
8618 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8619 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8620 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8621 clear_keybuf();
8622 show_mouse(screen);
8623
8624 DIALOG_PLAYER *p;
8625
8626 clear_bitmap(menu_bmp);
8627 oldscreen = screen;
8628 screen = menu_bmp;
8629
8630 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8631 {
8632 p = init_dialog(system_dlg2,-1);
8633 }
8634 else
8635 {
8636 p = init_dialog(system_dlg,-1);
8637 }
8638
8639 // drop the menu on startup if menu button pressed
8640 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8641 simulate_keypress(KEY_G << 8);
8642
8643 do
8644 {
8645 if(close_button_quit)
8646 {
8647 close_button_quit = false;
8648 f_Quit(qEXIT);
8649 if(Quit) break;
8650 }
8651 rest(17);
8652
8653 if(mouse_down && !gui_mouse_b())
8654 mouse_down=0;
8655
8656 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8657 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8658 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8659
8660 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8661 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8662 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8663 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8664 settings_menu[8].flags = NESquit?D_SELECTED:0;
8665 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8666 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8667 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8668 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8669 settings_menu[13].flags = volkeys?D_SELECTED:0;
8670 //Epilepsy Prevention
8671 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8672
8673 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8674 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8675 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8676
8677 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8678 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8679 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8680
8681 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8682 cheat_menu[0].flags = 0;
8683 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8684 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8685 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8686 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8687 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8688 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8689 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8690 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8691 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8692
8693 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8694 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8695 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8696 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8697 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8698 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8699 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8700 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8701 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8702 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8703 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8704 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8705 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8706 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8707 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8708
8709 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8710 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8711
8712 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8713 (char *)"Disable recording new saves" :
8714 (char *)"Enable recording new saves";
8715 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8716 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8717 (char *)"Stop recording" :
8718 (char *)"Stop replaying";
8719 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8720 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8721 (char *)"Disable snapshot all frames" :
8722 (char *)"Enable snapshot all frames";
8723
8724 reset_snapshot_format_menu();
8725 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8726
8727 if(debug_enabled)
8728 {
8729 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8730 }
8731
8732 if(gui_mouse_b() && !mouse_down)
8733 break;
8734
8735 // press menu to drop the menu
8736 if(rMbtn())
8737 simulate_keypress(KEY_G << 8);
8738
8739 if(input_idle(true) > after_time())
8740 // run Screeen Saver
8741 {
8742 // Screen saver enabled for now.
8743 clear_keybuf();
8744 scare_mouse();
8745 Matrix(ss_speed, ss_density, 0);
8746 system_pal();
8747 unscare_mouse();
8748 broadcast_dialog_message(MSG_DRAW, 0);
8749 }
8750
8751 update_hw_screen();
8752 }
8753 while(update_dialog(p));
8754
8755 screen = oldscreen;
8756
8757 // font=oldfont;
8758 mouse_down=gui_mouse_b();
8759 shutdown_dialog(p);
8760 show_mouse(NULL);
8761 MenuOpen = false;
8762 if(Quit)
8763 {
8764 kill_sfx();
8765 music_stop();
8766 update_hw_screen();
8767 }
8768 else
8769 {
8770 game_pal();
8771 music_resume();
8772 resume_all_sfx();
8773
8774 if(rc)
8775 ringcolor(false);
8776 }
8777
8778 eat_buttons();
8779
8780 rc=false;
8781 clear_keybuf();
8782 // text_mode(0);
8783 }
8784
8785 24 void fix_dialogs()
8786 {
8787 24 jwin_center_dialog(about_dlg);
8788 24 jwin_center_dialog(gamepad_dlg);
8789 24 jwin_center_dialog(credits_dlg);
8790 24 jwin_center_dialog(gamemode_dlg);
8791 24 jwin_center_dialog(getnum_dlg);
8792 24 jwin_center_dialog(goto_dlg);
8793 24 jwin_center_dialog(keyboard_control_dlg);
8794 24 jwin_center_dialog(midi_dlg);
8795 24 jwin_center_dialog(quest_dlg);
8796 24 jwin_center_dialog(scrsaver_dlg);
8797 24 jwin_center_dialog(sound_dlg);
8798 24 jwin_center_dialog(triforce_dlg);
8799
8800 // digi_dp[1] += scrx;
8801 // digi_dp[2] += scry;
8802 // midi_dp[1] += scrx;
8803 // midi_dp[2] += scry;
8804 // pan_dp[1] += scrx;
8805 // pan_dp[2] += scry;
8806 // emus_dp[1] += scrx;
8807 // emus_dp[2] += scry;
8808 // buf_dp[1] += scrx;
8809 // buf_dp[2] += scry;
8810 // sfx_dp[1] += scrx;
8811 // sfx_dp[2] += scry;
8812 24 }
8813
8814 /*****************************/
8815 /**** Custom Sound System ****/
8816 /*****************************/
8817
8818 1312 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8819 {
8820
3/4
✓ Branch 0 taken 1244 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 1312 times.
✗ Branch 3 not taken.
1312 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8821 }
8822
8823 // Run an NSF, or a MIDI if the NSF is missing somehow.
8824 64 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8825 {
8826 64 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8827
8828 // Found it
8829
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 25 times.
64 if(newzcmusic!=NULL)
8830 {
8831 39 zcmusic_stop(zcmusic);
8832 39 zcmusic_unload_file(zcmusic);
8833 39 zc_stop_midi();
8834
8835 39 zcmusic=newzcmusic;
8836 39 zcmusic_play(zcmusic, emusic_volume);
8837
8838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(track>0)
8839 39 zcmusic_change_track(zcmusic,track);
8840
8841 39 return true;
8842 }
8843
8844 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8845
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 else if(midi>-1000)
8846 jukebox(midi);
8847
8848 25 return false;
8849 64 }
8850
8851 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8852 {
8853 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8854 // Found it
8855 if(newzcmusic!=NULL)
8856 {
8857 zcmusic_stop(zcmusic);
8858 zcmusic_unload_file(zcmusic);
8859 zc_stop_midi();
8860
8861 zcmusic=newzcmusic;
8862 zcmusic_play(zcmusic, emusic_volume);
8863
8864 if(track>0)
8865 zcmusic_change_track(zcmusic,track);
8866
8867 return true;
8868 }
8869
8870 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8871 else if(midi>-1000)
8872 jukebox(midi);
8873
8874 return false;
8875 }
8876
8877 int32_t get_zcmusicpos()
8878 {
8879 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8880 return debugtracething;
8881 return 0;
8882 }
8883
8884 void set_zcmusicpos(int32_t position)
8885 {
8886 zcmusic_set_curpos(zcmusic, position);
8887 }
8888
8889 void set_zcmusicspeed(int32_t speed)
8890 {
8891 int32_t newspeed = vbound(speed, 0, 10000);
8892 zcmusic_set_speed(zcmusic, newspeed);
8893 }
8894
8895 644 void jukebox(int32_t index,int32_t loop)
8896 {
8897 644 music_stop();
8898
8899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(index<0) index=MAXMIDIS-1;
8900
8901
1/2
✓ Branch 0 taken 644 times.
✗ Branch 1 not taken.
644 if(index>=MAXMIDIS) index=0;
8902
8903 644 music_stop();
8904
8905 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8906 // stuck notes when a song stops. This fixes it.
8907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(strcmp(midi_driver->name, "DIGMID")==0)
8908 zc_set_volume(0, 0);
8909
8910 644 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8911 644 zc_play_midi((MIDI*)tunes[index].data,loop);
8912
8913
2/2
✓ Branch 0 taken 503 times.
✓ Branch 1 taken 141 times.
644 if(tunes[index].start>0)
8914 141 zc_midi_seek(tunes[index].start);
8915
8916 644 midi_loop_start = tunes[index].loop_start;
8917 644 midi_loop_end = tunes[index].loop_end;
8918
8919 644 currmidi=index;
8920 644 master_volume(digi_volume,midi_volume);
8921 644 midi_paused=false;
8922 644 }
8923
8924 4608 void jukebox(int32_t index)
8925 {
8926
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 if(index<0) index=MAXMIDIS-1;
8927
8928
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 if(index>=MAXMIDIS) index=0;
8929
8930 // do nothing if it's already playing
8931
3/4
✓ Branch 0 taken 3964 times.
✓ Branch 1 taken 644 times.
✓ Branch 2 taken 3964 times.
✗ Branch 3 not taken.
4608 if(index==currmidi && midi_pos>=0)
8932 {
8933 3964 midi_paused=false;
8934 3964 return;
8935 }
8936
8937 644 jukebox(index,tunes[index].loop);
8938 4608 }
8939
8940 5700 void play_DmapMusic()
8941 {
8942 static char tfile[2048];
8943 static int32_t ttrack=0;
8944 5700 bool domidi=false;
8945
8946
2/2
✓ Branch 0 taken 1201 times.
✓ Branch 1 taken 4499 times.
5700 if(DMaps[currdmap].tmusic[0]!=0)
8947 {
8948
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 816 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1586 if(zcmusic==NULL ||
8949
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8950
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8951 {
8952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816 times.
816 if(zcmusic != NULL)
8953 {
8954 zcmusic_stop(zcmusic);
8955 zcmusic_unload_file(zcmusic);
8956 zcmusic = NULL;
8957 }
8958
8959 816 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8960
8961
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 730 times.
816 if(zcmusic!=NULL)
8962 {
8963 86 zc_stop_midi();
8964 86 strcpy(tfile,DMaps[currdmap].tmusic);
8965 86 zcmusic_play(zcmusic, emusic_volume);
8966 86 int32_t temptracks=0;
8967 86 temptracks=zcmusic_get_tracks(zcmusic);
8968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8969 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8970 86 zcmusic_change_track(zcmusic,ttrack);
8971 86 }
8972 else
8973 {
8974 730 tfile[0] = 0;
8975 730 domidi=true;
8976 }
8977 816 }
8978 1201 }
8979 else
8980 {
8981 4499 domidi=true;
8982 }
8983
8984
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 5229 times.
5700 if(domidi)
8985 {
8986 5229 int32_t m=DMaps[currdmap].midi;
8987
8988
3/4
✓ Branch 0 taken 5130 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
5229 switch(m)
8989 {
8990 case 1:
8991 89 jukebox(ZC_MIDI_OVERWORLD);
8992 89 break;
8993
8994 case 2:
8995 10 jukebox(ZC_MIDI_DUNGEON);
8996 10 break;
8997
8998 case 3:
8999 jukebox(ZC_MIDI_LEVEL9);
9000 break;
9001
9002 default:
9003
3/4
✓ Branch 0 taken 4389 times.
✓ Branch 1 taken 741 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4389 times.
5130 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9004 4389 jukebox(m+MIDIOFFSET_DMAP);
9005 else
9006 741 music_stop();
9007 5130 }
9008 5229 }
9009 5700 }
9010
9011 5737 void playLevelMusic()
9012 {
9013 5737 int32_t m=tmpscr->screen_midi;
9014
9015
3/6
✓ Branch 0 taken 5684 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
5737 switch(m)
9016 {
9017 case -2:
9018 12 music_stop();
9019 12 break;
9020
9021 case -1:
9022 5684 play_DmapMusic();
9023 5684 break;
9024
9025 case 1:
9026 jukebox(ZC_MIDI_OVERWORLD);
9027 break;
9028
9029 case 2:
9030 jukebox(ZC_MIDI_DUNGEON);
9031 break;
9032
9033 case 3:
9034 jukebox(ZC_MIDI_LEVEL9);
9035 break;
9036
9037 default:
9038
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9039 41 jukebox(m+MIDIOFFSET_MAPSCR);
9040 else
9041 music_stop();
9042 41 }
9043 5737 }
9044
9045 668 void master_volume(int32_t dv,int32_t mv)
9046 {
9047
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 668 times.
✓ Branch 2 taken 668 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 668 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 668 times.
✗ Branch 7 not taken.
668 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9048
9049
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 668 times.
✓ Branch 2 taken 668 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 668 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 668 times.
✗ Branch 7 not taken.
668 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9050
9051
6/6
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 667 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 642 times.
✓ Branch 5 taken 25 times.
668 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9052 668 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9053 668 }
9054
9055 /*****************/
9056 /***** SFX *****/
9057 /*****************/
9058
9059 // array of voices, one for each sfx sample in the data file
9060 // 0+ = voice #
9061 // -1 = voice not allocated
9062 24 void Z_init_sound()
9063 {
9064
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<WAV_COUNT; i++)
9065 6144 sfx_voice[i]=-1;
9066
9067
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9068 168 tunes[i].data = (MIDI*)mididata[i].dat;
9069
9070
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 24 times.
6072 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9071 6048 tunes[ZC_MIDI_COUNT+j].data=NULL;
9072
9073 24 master_volume(digi_volume,midi_volume);
9074 24 }
9075
9076 // returns number of voices currently allocated
9077 int32_t sfx_count()
9078 {
9079 int32_t c=0;
9080
9081 for(int32_t i=0; i<WAV_COUNT; i++)
9082 if(sfx_voice[i]!=-1)
9083 ++c;
9084
9085 return c;
9086 }
9087
9088 // clean up finished samples
9089 4323298 void sfx_cleanup()
9090 {
9091
2/2
✓ Branch 0 taken 1106764288 times.
✓ Branch 1 taken 4323298 times.
1111087586 for(int32_t i=0; i<WAV_COUNT; i++)
9092
3/4
✓ Branch 0 taken 430539 times.
✓ Branch 1 taken 1106333749 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 430539 times.
1107194827 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9093 {
9094 430539 deallocate_voice(sfx_voice[i]);
9095 430539 sfx_voice[i]=-1;
9096 430539 }
9097 4323298 }
9098
9099 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9100 // if a voice is already allocated (and/or playing), then it just returns true
9101 // Returns true: voice is allocated
9102 // false: unsuccessful
9103 527784 bool sfx_init(int32_t index)
9104 {
9105 // check index
9106
3/4
✓ Branch 0 taken 467925 times.
✓ Branch 1 taken 59859 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 467925 times.
527784 if(index<=0 || index>=WAV_COUNT)
9107 59859 return false;
9108
9109
2/2
✓ Branch 0 taken 37366 times.
✓ Branch 1 taken 430559 times.
467925 if(sfx_voice[index]==-1)
9110 {
9111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 430559 times.
430559 if(sfxdat)
9112 {
9113 if(index<Z35)
9114 {
9115 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9116 }
9117 else
9118 {
9119 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9120 }
9121 }
9122 else
9123 {
9124 430559 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9125 }
9126
9127 430559 voice_set_volume(sfx_voice[index], sfx_volume);
9128 430559 }
9129
9130 467925 return sfx_voice[index] != -1;
9131 527784 }
9132
9133 // plays an sfx sample
9134 435537 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9135 {
9136
2/2
✓ Branch 0 taken 406935 times.
✓ Branch 1 taken 28602 times.
435537 if(!sfx_init(index))
9137 28602 return;
9138
9139 406935 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9140 406935 voice_set_pan(sfx_voice[index],pan);
9141
9142 406935 int32_t pos = voice_get_position(sfx_voice[index]);
9143
9144
2/2
✓ Branch 0 taken 227733 times.
✓ Branch 1 taken 179202 times.
406935 if(restart) voice_set_position(sfx_voice[index],0);
9145
9146
1/2
✓ Branch 0 taken 406935 times.
✗ Branch 1 not taken.
406935 if(pos<=0)
9147 406935 voice_start(sfx_voice[index]);
9148 435537 }
9149
9150 // true if sfx is allocated
9151 21668 bool sfx_allocated(int32_t index)
9152 {
9153
2/4
✓ Branch 0 taken 21668 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21668 times.
21668 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9154 }
9155
9156 // start it (in loop mode) if it's not already playing,
9157 // otherwise adjust it to play in loop mode -DD
9158 92247 void cont_sfx(int32_t index)
9159 {
9160
2/2
✓ Branch 0 taken 31257 times.
✓ Branch 1 taken 60990 times.
92247 if(!sfx_init(index))
9161 {
9162 31257 return;
9163 }
9164
9165
1/2
✓ Branch 0 taken 60990 times.
✗ Branch 1 not taken.
60990 if(voice_get_position(sfx_voice[index])<=0)
9166 {
9167 60990 voice_set_position(sfx_voice[index],0);
9168 60990 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9169 60990 voice_start(sfx_voice[index]);
9170 60990 }
9171 else
9172 {
9173 adjust_sfx(index, 128, true);
9174 }
9175 92247 }
9176
9177 // adjust parameters while playing
9178 2684 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9179 {
9180
5/6
✓ Branch 0 taken 1518 times.
✓ Branch 1 taken 1166 times.
✓ Branch 2 taken 1518 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1506 times.
2684 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9181 2672 return;
9182
9183 12 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9184 12 voice_set_pan(sfx_voice[index],pan);
9185 2684 }
9186
9187 // pauses a voice
9188 965 void pause_sfx(int32_t index)
9189 {
9190
3/6
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 965 times.
965 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9191 voice_stop(sfx_voice[index]);
9192 965 }
9193
9194 // resumes a voice
9195 460 void resume_sfx(int32_t index)
9196 {
9197
3/6
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 460 times.
460 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9198 voice_start(sfx_voice[index]);
9199 460 }
9200
9201 // pauses all active voices
9202 113 void pause_all_sfx()
9203 {
9204
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<WAV_COUNT; i++)
9205
2/2
✓ Branch 0 taken 28926 times.
✓ Branch 1 taken 2 times.
28930 if(sfx_voice[i]!=-1)
9206 2 voice_stop(sfx_voice[i]);
9207 113 }
9208
9209 // resumes all paused voices
9210 99 void resume_all_sfx()
9211 {
9212
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<WAV_COUNT; i++)
9213
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(sfx_voice[i]!=-1)
9214 voice_start(sfx_voice[i]);
9215 99 }
9216
9217 // stops an sfx and deallocates the voice
9218 3412320 void stop_sfx(int32_t index)
9219 {
9220
3/4
✓ Branch 0 taken 3324109 times.
✓ Branch 1 taken 88211 times.
✓ Branch 2 taken 3324109 times.
✗ Branch 3 not taken.
3412320 if(index<=0 || index>=WAV_COUNT)
9221 88211 return;
9222
9223
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3324096 times.
3324109 if(sfx_voice[index]!=-1)
9224 {
9225 13 deallocate_voice(sfx_voice[index]);
9226 13 sfx_voice[index]=-1;
9227 13 }
9228 3412320 }
9229
9230 // Stops SFX played by Hero's item of the given family
9231 17098 void stop_item_sfx(int32_t family)
9232 {
9233 17098 int32_t id=current_item_id(family);
9234
9235
2/2
✓ Branch 0 taken 16832 times.
✓ Branch 1 taken 266 times.
17098 if(id<0)
9236 16832 return;
9237
9238 266 stop_sfx(itemsbuf[id].usesound);
9239 17098 }
9240
9241 1164 void kill_sfx()
9242 {
9243
2/2
✓ Branch 0 taken 297984 times.
✓ Branch 1 taken 1164 times.
299148 for(int32_t i=0; i<WAV_COUNT; i++)
9244
2/2
✓ Branch 0 taken 297977 times.
✓ Branch 1 taken 7 times.
297991 if(sfx_voice[i]!=-1)
9245 {
9246 7 deallocate_voice(sfx_voice[i]);
9247 7 sfx_voice[i]=-1;
9248 7 }
9249 1164 }
9250
9251 366927 int32_t pan(int32_t x)
9252 {
9253
1/4
✓ Branch 0 taken 366927 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
366927 switch(pan_style)
9254 {
9255 case 0:
9256 return 128;
9257
9258 case 1:
9259 366927 return vbound((x>>1)+68,0,255);
9260
9261 case 2:
9262 return vbound(((x*3)>>2)+36,0,255);
9263 }
9264
9265 return vbound(x,0,255);
9266 366927 }
9267
9268 /*******************************/
9269 /******* Input Handlers ********/
9270 /*******************************/
9271
9272 10163347 bool joybtn(int32_t b)
9273 {
9274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10163347 times.
10163347 if(b == 0)
9275 return false;
9276
9277 10163347 return joy[joystick_index].button[b-1].b !=0;
9278 10163347 }
9279
9280 const char* joybtn_name(int32_t b)
9281 {
9282 if(b == 0)
9283 return "";
9284
9285 return joy[joystick_index].button[b-1].name;
9286 }
9287
9288 int32_t next_press_key()
9289 {
9290 return readkey()>>8;
9291 }
9292
9293 int32_t next_press_btn()
9294 {
9295 clear_keybuf();
9296 /*bool b[joy[joystick_index].num_buttons+1];
9297
9298 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9299 b[i]=joybtn(i);*/
9300
9301 //first, we need to wait until they're pressing no buttons
9302 for(;;)
9303 {
9304 if(keypressed())
9305 {
9306 switch(readkey()>>8)
9307 {
9308 case KEY_ESC:
9309 return -1;
9310
9311 case KEY_SPACE:
9312 return 0;
9313 }
9314 }
9315
9316 poll_joystick();
9317 bool done = true;
9318
9319 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9320 {
9321 if(joybtn(i)) done = false;
9322 }
9323
9324 if(done) break;
9325 rest(1);
9326 }
9327
9328 //now, we need to wait for them to press any button
9329 for(;;)
9330 {
9331 if(keypressed())
9332 {
9333 switch(readkey()>>8)
9334 {
9335 case KEY_ESC:
9336 return -1;
9337
9338 case KEY_SPACE:
9339 return 0;
9340 }
9341 }
9342
9343 poll_joystick();
9344
9345 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9346 {
9347 if(joybtn(i)) return i;
9348 }
9349 rest(1);
9350 }
9351 }
9352
9353 88537328 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9354 {
9355
2/2
✓ Branch 0 taken 85363374 times.
✓ Branch 1 taken 3173954 times.
88537328 bool ret = btn && !flag;
9356
2/2
✓ Branch 0 taken 83936597 times.
✓ Branch 1 taken 4600731 times.
88537328 flag = rawbtn ? *rawbtn : btn;
9357
9358 88537328 return ret;
9359 }
9360 864 static bool rButtonPeek(bool btn, bool flag)
9361 {
9362
2/2
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 36 times.
864 if(!btn)
9363 {
9364 828 return false;
9365 }
9366
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9367 {
9368 9 return true;
9369 }
9370
9371 27 return false;
9372 864 }
9373
9374 // Updated only by keyboard/gamepad.
9375 // If in replay mode, this is set directly by the replay system.
9376 // This should never be read from directly - use control_state instead.
9377 bool raw_control_state[ZC_CONTROL_STATES];
9378
9379 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9380 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9381 // lasts until the next call to load_control_state.
9382 bool control_state[ZC_CONTROL_STATES];
9383 bool disable_control[ZC_CONTROL_STATES];
9384 bool drunk_toggle_state[11];
9385 bool disabledKeys[127];
9386 bool KeyInput[127];
9387 bool KeyPress[127];
9388
9389 bool key_current_frame[127];
9390 bool key_previous_frame[127];
9391
9392 static bool key_system[127];
9393 static bool key_system_previous[127];
9394 static bool key_system_press[127];
9395
9396 bool button_press[ZC_CONTROL_STATES];
9397 bool button_hold[ZC_CONTROL_STATES];
9398
9399 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9400 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9401 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9402 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9403 #define STICK_PRECISION 56 //define your own sensitivity
9404
9405 3566133 void load_control_state()
9406 {
9407
4/4
✓ Branch 0 taken 3566130 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 694929 times.
✓ Branch 3 taken 2871201 times.
3566133 if (!replay_is_active() || replay_get_version() >= 8)
9408 {
9409
2/2
✓ Branch 0 taken 12508776 times.
✓ Branch 1 taken 694932 times.
13203708 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9410 12508776 down_control_states[i] = raw_control_state[i];
9411 694932 }
9412
9413
1/2
✓ Branch 0 taken 3566133 times.
✗ Branch 1 not taken.
3566133 if (!replay_is_replaying())
9414 {
9415 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9416 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9417 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9418 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9419 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9420 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9421 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9422 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9423 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9424 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9425 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9426 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9427 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9428 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9429
9430 if(num_joysticks != 0)
9431 {
9432 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9433 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9434 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9435 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9436 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9437 }
9438 else
9439 {
9440 raw_control_state[14] = false;
9441 raw_control_state[15] = false;
9442 raw_control_state[16] = false;
9443 raw_control_state[17] = false;
9444 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9445 }
9446 }
9447
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3566130 times.
3566133 if (replay_is_active())
9448 {
9449
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 2550915 times.
3566130 if (replay_get_version() < 3)
9450 1015215 replay_poll();
9451
3/4
✓ Branch 0 taken 2550915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 789540 times.
✓ Branch 3 taken 1761375 times.
2550915 else if (replay_is_replaying() && replay_get_version() < 6)
9452 1761375 replay_peek_input();
9453
3/4
✓ Branch 0 taken 789540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94608 times.
✓ Branch 3 taken 694932 times.
789540 else if (replay_is_replaying() && replay_get_version() >= 8)
9454 694932 replay_peek_input();
9455 3566130 }
9456
9457
3/4
✓ Branch 0 taken 3566127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 694932 times.
✓ Branch 3 taken 2871195 times.
3566133 if (!replay_is_active() || replay_get_version() >= 8)
9458 694932 update_keys();
9459
9460 // Some test replay files were made before a serious input bug was fixed, so instead
9461 // of re-doing them or tossing them out, just check for that zplay version.
9462
3/4
✓ Branch 0 taken 3566127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 3444227 times.
3566127 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9463
2/2
✓ Branch 0 taken 3566127 times.
✓ Branch 1 taken 64190286 times.
67756413 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9464 {
9465 64190286 control_state[i] = raw_control_state[i];
9466
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 14702976 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
64190286 if (botched_input && !control_state[i])
9467 47077142 down_control_states[i] = false;
9468 64190286 }
9469
9470 3566127 button_press[0]=rButton(control_state[0],button_hold[0]);
9471 3566127 button_press[1]=rButton(control_state[1],button_hold[1]);
9472 3566127 button_press[2]=rButton(control_state[2],button_hold[2]);
9473 3566127 button_press[3]=rButton(control_state[3],button_hold[3]);
9474 3566127 button_press[4]=rButton(control_state[4],button_hold[4]);
9475 3566127 button_press[5]=rButton(control_state[5],button_hold[5]);
9476 3566127 button_press[6]=rButton(control_state[6],button_hold[6]);
9477 3566127 button_press[7]=rButton(control_state[7],button_hold[7]);
9478 3566127 button_press[8]=rButton(control_state[8],button_hold[8]);
9479 3566127 button_press[9]=rButton(control_state[9],button_hold[9]);
9480 3566127 button_press[10]=rButton(control_state[10],button_hold[10]);
9481 3566127 button_press[11]=rButton(control_state[11],button_hold[11]);
9482 3566127 button_press[12]=rButton(control_state[12],button_hold[12]);
9483 3566127 button_press[13]=rButton(control_state[13],button_hold[13]);
9484 3566127 button_press[14]=rButton(control_state[14],button_hold[14]);
9485 3566127 button_press[15]=rButton(control_state[15],button_hold[15]);
9486 3566127 button_press[16]=rButton(control_state[16],button_hold[16]);
9487 3566127 button_press[17]=rButton(control_state[17],button_hold[17]);
9488 3566127 }
9489
9490 // Returns true if any game key is pressed. This is needed because keypressed()
9491 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9492 18343046 bool zc_key_pressed()
9493 //may also need to use zc_getrawkey
9494 {
9495
7/10
✓ Branch 0 taken 14775148 times.
✓ Branch 1 taken 3567898 times.
✓ Branch 2 taken 3567898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3567898 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2984610 times.
✓ Branch 7 taken 2984610 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 991354 times.
19334400 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9496
4/6
✓ Branch 0 taken 2984610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2984610 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2240879 times.
✓ Branch 5 taken 2240879 times.
2984610 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9497
4/6
✓ Branch 0 taken 2240879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2240879 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1433185 times.
✓ Branch 5 taken 1433185 times.
2240879 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9498
4/6
✓ Branch 0 taken 1433185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1433185 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1140669 times.
✓ Branch 5 taken 1140669 times.
1433185 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9499
1/2
✓ Branch 0 taken 1140669 times.
✗ Branch 1 not taken.
1140669 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9500
3/4
✓ Branch 0 taken 1066092 times.
✓ Branch 1 taken 74577 times.
✓ Branch 2 taken 1066092 times.
✗ Branch 3 not taken.
1140669 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9501
3/4
✓ Branch 0 taken 1005632 times.
✓ Branch 1 taken 60460 times.
✓ Branch 2 taken 1005632 times.
✗ Branch 3 not taken.
1066092 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9502
3/4
✓ Branch 0 taken 999953 times.
✓ Branch 1 taken 5679 times.
✓ Branch 2 taken 999953 times.
✗ Branch 3 not taken.
1005632 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9503
3/4
✓ Branch 0 taken 992581 times.
✓ Branch 1 taken 7372 times.
✓ Branch 2 taken 992581 times.
✗ Branch 3 not taken.
999953 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9504
3/4
✓ Branch 0 taken 992181 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 992181 times.
✗ Branch 3 not taken.
992581 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9505
3/4
✓ Branch 0 taken 992139 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 992139 times.
✗ Branch 3 not taken.
992181 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9506
3/4
✓ Branch 0 taken 991373 times.
✓ Branch 1 taken 766 times.
✓ Branch 2 taken 991373 times.
✗ Branch 3 not taken.
992139 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9507
2/4
✓ Branch 0 taken 991373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 991373 times.
✗ Branch 3 not taken.
991373 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9508
2/2
✓ Branch 0 taken 991354 times.
✓ Branch 1 taken 19 times.
991373 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9509 32950378 return true;
9510
9511 991354 return false;
9512 4391436 }
9513
9514 70672442 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9515 {
9516 70672442 bool ret = false, drunkstate = false, rawret = false;
9517 70672442 bool* flag = &down_control_states[btn];
9518
2/7
✓ Branch 0 taken 66276307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 4396135 times.
70672442 switch(btn)
9519 {
9520 case btnF12:
9521 ret = zc_getkey(KEY_F12, ignoreDisable);
9522 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9523 eatEntirely = false;
9524 break;
9525 case btnF11:
9526 ret = zc_getkey(KEY_F11, ignoreDisable);
9527 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9528 eatEntirely = false;
9529 break;
9530 case btnF5:
9531 ret = zc_getkey(KEY_F5, ignoreDisable);
9532 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9533 eatEntirely = false;
9534 break;
9535 case btnQ:
9536 ret = zc_getkey(KEY_Q, ignoreDisable);
9537 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9538 eatEntirely = false;
9539 break;
9540 case btnI:
9541 ret = zc_getkey(KEY_I, ignoreDisable);
9542 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9543 eatEntirely = false;
9544 break;
9545 case btnM:
9546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4396135 times.
4396135 if(FFCore.kb_typing_mode) return false;
9547 4396135 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9548 4396135 eatEntirely = false;
9549 4396135 break;
9550 default: //control_state[] index
9551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66276307 times.
66276307 if(FFCore.kb_typing_mode) return false;
9552
5/6
✓ Branch 0 taken 66127038 times.
✓ Branch 1 taken 149269 times.
✓ Branch 2 taken 1904881 times.
✓ Branch 3 taken 64222157 times.
✓ Branch 4 taken 1904881 times.
✗ Branch 5 not taken.
66276307 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9553
2/2
✓ Branch 0 taken 3614535 times.
✓ Branch 1 taken 62661772 times.
66276307 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9554
4/4
✓ Branch 0 taken 59318873 times.
✓ Branch 1 taken 6957434 times.
✓ Branch 2 taken 1152 times.
✓ Branch 3 taken 6956282 times.
73233741 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9555 66276307 rawret = raw_control_state[btn];
9556 66276307 }
9557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70672442 times.
70672442 assert(flag);
9558
2/2
✓ Branch 0 taken 46324536 times.
✓ Branch 1 taken 24347906 times.
70672442 if(press)
9559 {
9560
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 24347042 times.
24347906 if(peek)
9561 864 ret = rButtonPeek(ret, *flag);
9562
3/4
✓ Branch 0 taken 24347042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4600731 times.
✓ Branch 3 taken 19746311 times.
24347042 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9563 4600731 else ret = rButton(ret, *flag, &rawret);
9564 24347906 }
9565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 70672442 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
70672442 if(eatEntirely && ret) control_state[btn] = false;
9566
3/4
✓ Branch 0 taken 54199484 times.
✓ Branch 1 taken 16472958 times.
✓ Branch 2 taken 54199484 times.
✗ Branch 3 not taken.
70672442 if(drunk && drunkstate) ret = !ret;
9567 70672442 return ret;
9568 70672442 }
9569
9570 369200 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9571 {
9572 369200 byte ret = 0;
9573
2/2
✓ Branch 0 taken 366817 times.
✓ Branch 1 taken 2383 times.
369200 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9574
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9575
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9576
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9577
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9578
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9579
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9580
1/2
✓ Branch 0 taken 369200 times.
✗ Branch 1 not taken.
369200 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9581 369200 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9582 }
9583
9584 561 byte checkIntBtnVal(byte intbtn, byte vals)
9585 {
9586 561 return intbtn&vals;
9587 }
9588
9589 741878 bool Up()
9590 {
9591 741878 return getInput(btnUp);
9592 }
9593 39102 bool Down()
9594 {
9595 39102 return getInput(btnDown);
9596 }
9597 61082 bool Left()
9598 {
9599 61082 return getInput(btnLeft);
9600 }
9601 64571 bool Right()
9602 {
9603 64571 return getInput(btnRight);
9604 }
9605 37406 bool cAbtn()
9606 {
9607 37406 return getInput(btnA);
9608 }
9609 661269 bool cBbtn()
9610 {
9611 661269 return getInput(btnB);
9612 }
9613 bool cSbtn()
9614 {
9615 return getInput(btnS);
9616 }
9617 6440 bool cLbtn()
9618 {
9619 6440 return getInput(btnL);
9620 }
9621 6440 bool cRbtn()
9622 {
9623 6440 return getInput(btnR);
9624 }
9625 bool cPbtn()
9626 {
9627 return getInput(btnP);
9628 }
9629 bool cEx1btn()
9630 {
9631 return getInput(btnEx1);
9632 }
9633 bool cEx2btn()
9634 {
9635 return getInput(btnEx2);
9636 }
9637 bool cEx3btn()
9638 {
9639 return getInput(btnEx3);
9640 }
9641 bool cEx4btn()
9642 {
9643 return getInput(btnEx4);
9644 }
9645 bool AxisUp()
9646 {
9647 return getInput(btnAxisUp);
9648 }
9649 bool AxisDown()
9650 {
9651 return getInput(btnAxisDown);
9652 }
9653 bool AxisLeft()
9654 {
9655 return getInput(btnAxisLeft);
9656 }
9657 bool AxisRight()
9658 {
9659 return getInput(btnAxisRight);
9660 }
9661
9662 bool cMbtn()
9663 {
9664 return getInput(btnM);
9665 }
9666 bool cF12()
9667 {
9668 return getInput(btnF12);
9669 }
9670 bool cF11()
9671 {
9672 return getInput(btnF11);
9673 }
9674 bool cF5()
9675 {
9676 return getInput(btnF5);
9677 }
9678 bool cQ()
9679 {
9680 return getInput(btnQ);
9681 }
9682 bool cI()
9683 {
9684 return getInput(btnI);
9685 }
9686
9687 66879 bool rUp()
9688 {
9689 66879 return getInput(btnUp, true);
9690 }
9691 66835 bool rDown()
9692 {
9693 66835 return getInput(btnDown, true);
9694 }
9695 66805 bool rLeft()
9696 {
9697 66805 return getInput(btnLeft, true);
9698 }
9699 66396 bool rRight()
9700 {
9701 66396 return getInput(btnRight, true);
9702 }
9703 357 bool rAbtn()
9704 {
9705 357 return getInput(btnA, true);
9706 }
9707 67218 bool rBbtn()
9708 {
9709 67218 return getInput(btnB, true);
9710 }
9711 3463234 bool rSbtn()
9712 {
9713 3463234 return getInput(btnS, true);
9714 }
9715 4391436 bool rMbtn()
9716 {
9717 4391436 return getInput(btnM, true);
9718 }
9719 66242 bool rLbtn()
9720 {
9721 66242 return getInput(btnL, true);
9722 }
9723 66239 bool rRbtn()
9724 {
9725 66239 return getInput(btnR, true);
9726 }
9727 3401905 bool rPbtn()
9728 {
9729 3401905 return getInput(btnP, true);
9730 }
9731 bool rEx1btn()
9732 {
9733 return getInput(btnEx1, true);
9734 }
9735 bool rEx2btn()
9736 {
9737 return getInput(btnEx2, true);
9738 }
9739 66799 bool rEx3btn()
9740 {
9741 66799 return getInput(btnEx3, true);
9742 }
9743 66799 bool rEx4btn()
9744 {
9745 66799 return getInput(btnEx4, true);
9746 }
9747 bool rAxisUp()
9748 {
9749 return getInput(btnAxisUp, true);
9750 }
9751 bool rAxisDown()
9752 {
9753 return getInput(btnAxisDown, true);
9754 }
9755 bool rAxisLeft()
9756 {
9757 return getInput(btnAxisLeft, true);
9758 }
9759 bool rAxisRight()
9760 {
9761 return getInput(btnAxisRight, true);
9762 }
9763
9764 bool rF11()
9765 {
9766 return getInput(btnF11, true);
9767 }
9768 bool rQ()
9769 {
9770 return getInput(btnQ, true);
9771 }
9772 bool rI()
9773 {
9774 return getInput(btnI, true);
9775 }
9776
9777 8923805 bool DrunkUp()
9778 {
9779 8923805 return getInput(btnUp, false, true);
9780 }
9781 8305366 bool DrunkDown()
9782 {
9783 8305366 return getInput(btnDown, false, true);
9784 }
9785 5430208 bool DrunkLeft()
9786 {
9787 5430208 return getInput(btnLeft, false, true);
9788 }
9789 4783920 bool DrunkRight()
9790 {
9791 4783920 return getInput(btnRight, false, true);
9792 }
9793 3877591 bool DrunkcAbtn()
9794 {
9795 3877591 return getInput(btnA, false, true);
9796 }
9797 3751464 bool DrunkcBbtn()
9798 {
9799 3751464 return getInput(btnB, false, true);
9800 }
9801 3395158 bool DrunkcEx1btn()
9802 {
9803 3395158 return getInput(btnEx1, false, true);
9804 }
9805 3395178 bool DrunkcEx2btn()
9806 {
9807 3395178 return getInput(btnEx2, false, true);
9808 }
9809 bool DrunkcSbtn()
9810 {
9811 return getInput(btnS, false, true);
9812 }
9813 bool DrunkcMbtn()
9814 {
9815 return getInput(btnM, false, true);
9816 }
9817 bool DrunkcLbtn()
9818 {
9819 return getInput(btnL, false, true);
9820 }
9821 bool DrunkcRbtn()
9822 {
9823 return getInput(btnR, false, true);
9824 }
9825 bool DrunkcPbtn()
9826 {
9827 return getInput(btnP, false, true);
9828 }
9829
9830 bool DrunkrUp()
9831 {
9832 return getInput(btnUp, true, true);
9833 }
9834 bool DrunkrDown()
9835 {
9836 return getInput(btnDown, true, true);
9837 }
9838 bool DrunkrLeft()
9839 {
9840 return getInput(btnLeft, true, true);
9841 }
9842 bool DrunkrRight()
9843 {
9844 return getInput(btnRight, true, true);
9845 }
9846 2791344 bool DrunkrAbtn()
9847 {
9848 2791344 return getInput(btnA, true, true);
9849 }
9850 2781833 bool DrunkrBbtn()
9851 {
9852 2781833 return getInput(btnB, true, true);
9853 }
9854 71669 bool DrunkrEx1btn()
9855 {
9856 71669 return getInput(btnEx1, true, true);
9857 }
9858 71662 bool DrunkrEx2btn()
9859 {
9860 71662 return getInput(btnEx2, true, true);
9861 }
9862 bool DrunkrEx3btn()
9863 {
9864 return getInput(btnEx3, true, true);
9865 }
9866 bool DrunkrEx4btn()
9867 {
9868 return getInput(btnEx4, true, true);
9869 }
9870 bool DrunkrSbtn()
9871 {
9872 return getInput(btnS, true, true);
9873 }
9874 bool DrunkrMbtn()
9875 {
9876 return getInput(btnM, true, true);
9877 }
9878 3309860 bool DrunkrLbtn()
9879 {
9880 3309860 return getInput(btnL, true, true);
9881 }
9882 3308043 bool DrunkrRbtn()
9883 {
9884 3308043 return getInput(btnR, true, true);
9885 }
9886 bool DrunkrPbtn()
9887 {
9888 return getInput(btnP, true, true);
9889 }
9890
9891 4699 void eat_buttons()
9892 {
9893 4699 getInput(btnA, true, false, true);
9894 4699 getInput(btnB, true, false, true);
9895 4699 getInput(btnS, true, false, true);
9896 4699 getInput(btnM, true, false, true);
9897 4699 getInput(btnL, true, false, true);
9898 4699 getInput(btnR, true, false, true);
9899 4699 getInput(btnP, true, false, true);
9900 4699 getInput(btnEx1, true, false, true);
9901 4699 getInput(btnEx2, true, false, true);
9902 4699 getInput(btnEx3, true, false, true);
9903 4699 getInput(btnEx4, true, false, true);
9904 4699 }
9905
9906 // Is true for the _first frame_ of a key press.
9907 // But! it is possible that a script manually sets the value of KeyPress,
9908 // in which case it will be restored to the "true" value based on `key_current_frame`
9909 // and `key_previous_frame` on the next frame.
9910 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9911 {
9912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9914 {
9915 case KEY_F7:
9916 case KEY_F8:
9917 case KEY_F9:
9918 return KeyPress[k];
9919
9920 default:
9921
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9922 }
9923 14 }
9924
9925 // Is true for _every frame_ a key is held down.
9926 // But! it is possible that a script manually sets the value of KeyInput,
9927 // in which case it will be restored to the "true" value based on `key_current_frame`
9928 // on the next frame.
9929 bool zc_getkey(int32_t k, bool ignoreDisable)
9930 {
9931 if(ignoreDisable) return KeyInput[k];
9932 switch(k)
9933 {
9934 case KEY_F7:
9935 case KEY_F8:
9936 case KEY_F9:
9937 return KeyInput[k];
9938
9939 default:
9940 return KeyInput[k] && !disabledKeys[k];
9941 }
9942 }
9943
9944 // Reads (and then clears) the current frame key state directly.
9945 // Scripts can also modify `key_current_frame`.
9946 28744561 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9947 {
9948
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 28744560 times.
28744561 if(zc_getrawkey(k, ignoreDisable))
9949 {
9950 1 _key[k]=key[k]=key_current_frame[k]=0;
9951 1 return true;
9952 }
9953 28744560 _key[k]=key[k]=key_current_frame[k]=0;
9954 28744560 return false;
9955 28744561 }
9956
9957 // Reads the current frame key state directly.
9958 // Scripts can also modify `key_current_frame`.
9959 56930697 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9960 {
9961
2/2
✓ Branch 0 taken 23794741 times.
✓ Branch 1 taken 33135956 times.
56930697 if(ignoreDisable) return key_current_frame[k];
9962
2/2
✓ Branch 0 taken 14372246 times.
✓ Branch 1 taken 18763710 times.
33135956 switch(k)
9963 {
9964 case KEY_F7:
9965 case KEY_F8:
9966 case KEY_F9:
9967 14372246 return key_current_frame[k];
9968
9969 default:
9970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18763710 times.
18763710 return key_current_frame[k] && !disabledKeys[k];
9971 }
9972 56930697 }
9973
9974 // Only used for a handful of keys, like tilde and Function keys.
9975 // This state is never read within the game.
9976 // It exists so that all keyboard input still functions during replay,
9977 // without inadvertently doing things like toggling throttling if the player
9978 // presses ~
9979 8659519 bool zc_get_system_key(int32_t k)
9980 {
9981 8659519 return key_system[k];
9982 }
9983
9984 // True for the _first_ frame of a key press.
9985 39522924 bool zc_read_system_key(int32_t k)
9986 {
9987 39522924 return key_system_press[k];
9988 }
9989
9990 557712372 bool is_system_key(int32_t k)
9991 {
9992
2/2
✓ Branch 0 taken 518189448 times.
✓ Branch 1 taken 39522924 times.
557712372 switch (k)
9993 {
9994 case KEY_BACKQUOTE:
9995 case KEY_CLOSEBRACE:
9996 case KEY_END:
9997 case KEY_HOME:
9998 case KEY_OPENBRACE:
9999 case KEY_PGDN:
10000 case KEY_PGUP:
10001 case KEY_TAB:
10002 case KEY_TILDE:
10003 39522924 return true;
10004 }
10005 518189448 return is_Fkey(k);
10006 557712372 }
10007
10008 4391436 void update_system_keys()
10009 {
10010 4391436 poll_keyboard();
10011
2/2
✓ Branch 0 taken 557712372 times.
✓ Branch 1 taken 4391436 times.
562103808 for (int32_t q = 0; q < 127; ++q)
10012 {
10013
2/2
✓ Branch 0 taken 92220156 times.
✓ Branch 1 taken 465492216 times.
557712372 if (!is_system_key(q))
10014 465492216 continue;
10015
10016 92220156 key_system[q] = key[q];
10017
1/2
✓ Branch 0 taken 92220156 times.
✗ Branch 1 not taken.
92220156 key_system_press[q] = key_system[q] && !key_system_previous[q];
10018 92220156 key_system_previous[q] = key_system[q];
10019 92220156 }
10020 4391436 }
10021
10022 5024670 void update_keys()
10023 {
10024
1/2
✓ Branch 0 taken 5024670 times.
✗ Branch 1 not taken.
5024670 if (!replay_is_replaying())
10025 poll_keyboard();
10026
10027
2/2
✓ Branch 0 taken 5024670 times.
✓ Branch 1 taken 638133090 times.
643157760 for (int32_t q = 0; q < 127; ++q)
10028 {
10029 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10030
1/2
✓ Branch 0 taken 638133090 times.
✗ Branch 1 not taken.
638133090 if (!replay_is_replaying())
10031 key_current_frame[q] = key[q];
10032
10033
2/2
✓ Branch 0 taken 633834751 times.
✓ Branch 1 taken 4298339 times.
638133090 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10034 638133090 KeyInput[q] = key_current_frame[q];
10035 638133090 key_previous_frame[q] = key_current_frame[q];
10036 638133090 }
10037 5024670 }
10038
10039 bool zc_disablekey(int32_t k, bool val)
10040 {
10041 switch(k)
10042 {
10043 case KEY_F7:
10044 case KEY_F8:
10045 case KEY_F9:
10046 return false;
10047
10048 default:
10049 disabledKeys[k] = val;
10050 return true;
10051 }
10052 }
10053
10054 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10055 {
10056 timer=timer;
10057 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10058 }
10059
10060 // these are here so that copy_dialog won't choke when compiling zelda
10061 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10062 {
10063 return D_O_K;
10064 }
10065
10066 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10067 {
10068 return D_O_K;
10069 }
10070
10071 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10072 {
10073 return D_O_K;
10074 }
10075
10076 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10077 {
10078 return D_O_K;
10079 }
10080
10081 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10082 {
10083 return D_O_K;
10084 }
10085
10086 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10087 {
10088 return D_O_K;
10089 }
10090
10091 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10092 {
10093 return D_O_K;
10094 }
10095
10096 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10097 {
10098 return D_O_K;
10099 }
10100
10101 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10102 {
10103 return D_O_K;
10104 }
10105
10106 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10107 {
10108 return D_O_K;
10109 }
10110
10111 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10112 {
10113 return D_O_K;
10114 }
10115
10116 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10117 {
10118 return D_O_K;
10119 }
10120
10121 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10122 {
10123 return D_O_K;
10124 }
10125
10126 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10127 {
10128 return D_O_K;
10129 }
10130
10131 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10132 {
10133 return D_O_K;
10134 }
10135
10136 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10137 {
10138 return D_O_K;
10139 }
10140
10141 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10142 {
10143 return D_O_K;
10144 }
10145
10146 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10147 {
10148 return D_O_K;
10149 }
10150
10151 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10152 {
10153 return D_O_K;
10154 }
10155
10156 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10157 {
10158 return D_O_K;
10159 }
10160
10161 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10162 {
10163 return D_O_K;
10164 }
10165
10166 /*** end of zc_sys.cc ***/
10167
10168